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 ddfea90
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 46 deletions.
62 changes: 31 additions & 31 deletions src/rs/examples/random_scramble_for_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,38 @@ use twsearch::scramble::{random_scramble_for_event, Event};

pub fn main() {
for event in [
Event::Cube3x3x3Speedsolving,
Event::Cube3x3x3Speedsolving,
Event::Cube3x3x3Speedsolving,
Event::Cube3x3x3Speedsolving,
Event::Cube3x3x3Speedsolving,
Event::Cube2x2x2Speedsolving,
Event::Cube5x5x5Speedsolving,
Event::Cube6x6x6Speedsolving,
Event::Cube7x7x7Speedsolving,
Event::Cube3x3x3Blindfolded,
Event::Cube3x3x3FewestMoves,
Event::Cube3x3x3OneHanded,
Event::MegaminxSpeedsolving,
Event::PyraminxSpeedsolving,
Event::Cube5x5x5Blindfolded,
Event::Cube3x3x3MultiBlind,
Event::ClockSpeedsolving,
Event::SkewbSpeedsolving,
Event::Cube3x3x3FewestMoves,
Event::Cube3x3x3FewestMoves,
Event::Cube3x3x3FewestMoves,
Event::Cube3x3x3FewestMoves,
Event::Cube3x3x3FewestMoves,
Event::Cube3x3x3FewestMoves,
Event::Cube3x3x3FewestMoves,
Event::Cube3x3x3FewestMoves,
Event::Cube3x3x3FewestMoves,
Event::Cube3x3x3FewestMoves,
Event::Cube3x3x3FewestMoves,
Event::Cube3x3x3FewestMoves,
Event::Cube3x3x3FewestMoves,
Event::Cube3x3x3FewestMoves,
//<<< Event::Cube3x3x3Speedsolving,
//<<< Event::Cube3x3x3Speedsolving,
//<<< Event::Cube3x3x3Speedsolving,
//<<< Event::Cube3x3x3Speedsolving,
//<<< Event::Cube3x3x3Speedsolving,
//<<< Event::Cube2x2x2Speedsolving,
//<<< Event::Cube5x5x5Speedsolving,
//<<< Event::Cube6x6x6Speedsolving,
//<<< Event::Cube7x7x7Speedsolving,
//<<< Event::Cube3x3x3Blindfolded,
//<<< Event::Cube3x3x3FewestMoves,
//<<< Event::Cube3x3x3OneHanded,
//<<< Event::MegaminxSpeedsolving,
//<<< Event::PyraminxSpeedsolving,
//<<< Event::Cube5x5x5Blindfolded,
//<<< Event::Cube3x3x3MultiBlind,
//<<< Event::ClockSpeedsolving,
//<<< Event::Cube3x3x3FewestMoves,
//<<< Event::Cube3x3x3FewestMoves,
//<<< Event::Cube3x3x3FewestMoves,
//<<< Event::Cube3x3x3FewestMoves,
//<<< Event::Cube3x3x3FewestMoves,
//<<< Event::Cube3x3x3FewestMoves,
//<<< Event::Cube3x3x3FewestMoves,
//<<< Event::Cube3x3x3FewestMoves,
//<<< Event::Cube3x3x3FewestMoves,
//<<< Event::Cube3x3x3FewestMoves,
//<<< Event::Cube3x3x3FewestMoves,
//<<< Event::Cube3x3x3FewestMoves,
//<<< Event::Cube3x3x3FewestMoves,
//<<< Event::Cube3x3x3FewestMoves,
] {
let start_time = Instant::now();
let scramble = random_scramble_for_event(event).unwrap();
Expand Down
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 ddfea90

Please sign in to comment.