Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Odilf committed Aug 14, 2023
1 parent ffb04c2 commit 8950f0d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions barbarosa/src/cube_n/cube3/cfop/cross.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ fn solve_cross_directly(
pub fn good_cross_heuristic(cube: &Cube3, bottom_face: &Face) -> f32 {
cube.edges
.iter_with_pos()
.filter(|(original, _)| is_cross_edge(&original, bottom_face))
.map(|(original, edge)| min_moves_to_solve(&original, &edge))
.filter(|(original, _)| is_cross_edge(original, bottom_face))
.map(|(original, edge)| min_moves_to_solve(&original, edge))
.sum::<i32>() as f32
/ 2.0 // Constant is kinda arbitrary to improve performance
}
Expand All @@ -98,8 +98,8 @@ pub fn good_cross_heuristic(cube: &Cube3, bottom_face: &Face) -> f32 {
pub fn worse_but_admissable_cross_heuristic(cube: &Cube3, bottom_face: &Face) -> f32 {
cube.edges
.iter_with_pos()
.filter(|(original, _)| is_cross_edge(&original, &bottom_face))
.map(|(original, edge)| min_moves_to_solve(&original, &edge))
.filter(|(original, _)| is_cross_edge(original, bottom_face))
.map(|(original, edge)| min_moves_to_solve(&original, edge))
.max()
.expect("Edges have 12 items, which is greater 0") as f32
}
4 changes: 2 additions & 2 deletions barbarosa/src/cube_n/pieces/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,15 @@ pub type EdgeSet = PieceSet<Edge, 12>;
///
/// Useful as an admissable heuristic
pub fn min_moves_to_solve(original_pos: &<Edge as Piece>::Position, edge: &Edge) -> i32 {
if edge.is_solved(&original_pos) {
if edge.is_solved(original_pos) {
return 0;
}

let (normal, _) = &original_pos;

let shared_axis = Axis::iter().find(|axis| {
let d1 = Edge::direction_on_axis(&edge.position(), *axis);
let d2 = Edge::direction_on_axis(&original_pos, *axis);
let d2 = Edge::direction_on_axis(original_pos, *axis);

d1.is_some() && d1 == d2
});
Expand Down

0 comments on commit 8950f0d

Please sign in to comment.