Skip to content

Commit

Permalink
Remove the max_scramble_moves parameter from filtered_search(…) a…
Browse files Browse the repository at this point in the history
…gain.
  • Loading branch information
lgarron committed Sep 14, 2024
1 parent 345b8be commit 6766fb7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/rs/scramble/puzzles/cube2x2x2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub fn scramble_2x2x2() -> Alg {
OrbitOrientationConstraint::OrientationsMustSumToZero,
);
let generators = generators_from_vec_str(vec!["U", "L", "F", "R"]);
if let Some(scramble) = filtered_search(&scramble_pattern, generators, 4, Some(11), None) {
if let Some(scramble) = filtered_search(&scramble_pattern, generators, 4, Some(11)) {
return scramble;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/rs/scramble/puzzles/pyraminx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn scramble_pyraminx() -> Alg {

let mut rng = thread_rng();
let generators = generators_from_vec_str(vec!["U", "L", "R", "B"]); // TODO: cache
if let Some(scramble) = filtered_search(&scramble_pattern, generators, 4, Some(11), None) {
if let Some(scramble) = filtered_search(&scramble_pattern, generators, 4, Some(11)) {
let mut alg_nodes: Vec<AlgNode> = vec![];
for tip_move in tip_moves {
let amount = rng.gen_range(-1..=1);
Expand Down
2 changes: 1 addition & 1 deletion src/rs/scramble/puzzles/skewb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub fn scramble_skewb() -> Alg {
);

let generators = generators_from_vec_str(vec!["U", "L", "R", "B"]); // TODO: cache
if let Some(scramble) = filtered_search(&scramble_pattern, generators, 7, Some(11), Some(11)) {
if let Some(scramble) = filtered_search(&scramble_pattern, generators, 7, Some(11)) {
return scramble;
}
}
Expand Down
26 changes: 14 additions & 12 deletions src/rs/scramble/scramble_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ pub(crate) fn filtered_search(
generators: Generators,
min_optimal_moves: usize,
min_scramble_moves: Option<usize>,
max_scramble_moves: Option<usize>,
) -> Option<Alg> {
assert_ne!(min_optimal_moves, 0);

Expand All @@ -79,16 +78,19 @@ pub(crate) fn filtered_search(
{
return None;
}
idfs.search(
scramble_pattern,
IndividualSearchOptions {
min_num_solutions: Some(1),
min_depth: min_scramble_moves,
max_depth: max_scramble_moves.map(|n| n + 1),
disallowed_initial_quanta: None,
disallowed_final_quanta: None,
},
Some(
idfs.search(
scramble_pattern,
IndividualSearchOptions {
min_num_solutions: Some(1),
min_depth: min_scramble_moves,
max_depth: None,
disallowed_initial_quanta: None,
disallowed_final_quanta: None,
},
)
.next()
.unwrap()
.invert(),
)
.next()
.map(|alg| alg.invert())
}

0 comments on commit 6766fb7

Please sign in to comment.