Skip to content

Commit

Permalink
Change Square-1 phase 2 to use smaller coordinate tables using clever…
Browse files Browse the repository at this point in the history
… math. (#102)

This reduces initialization from over 5 seconds to about 1.

Before:

```shell
# 5.5 seconds
cargo build --release && time ./target/release/twsearch scramble --amount 1 sq1

# 9.9 seconds
cargo build --release && time ./target/release/twsearch scramble --amount 100 sq1
```

After:

```shell
# 0.95 seconds
cargo build --release && time ./target/release/twsearch scramble --amount 1 sq1

# 5.7 seconds
cargo build --release && time ./target/release/twsearch scramble --amount 100 sq1
```

We can still gain more — #101
is for that.
  • Loading branch information
lgarron authored Feb 2, 2025
2 parents 61dacc9 + 3ee1abb commit c27ee05
Show file tree
Hide file tree
Showing 5 changed files with 497 additions and 63 deletions.
10 changes: 5 additions & 5 deletions src/rs/_internal/search/coordinates/phase_coordinate_puzzle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ where
}

// TODO: place this behind `SearchLogger`.
eprintln!(
"[PhaseCoordinatePuzzle] {} has {} patterns.",
TSemanticCoordinate::phase_name(),
index_to_semantic_coordinate.len()
);
// eprintln!(
// "[PhaseCoordinatePuzzle] {} has {} patterns.",
// TSemanticCoordinate::phase_name(),
// index_to_semantic_coordinate.len()
// );

let mut move_application_table: IndexedVec<
PhaseCoordinateIndex<Self>,
Expand Down
6 changes: 1 addition & 5 deletions src/rs/scramble/puzzles/square1/phase1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ impl PatternValidityChecker<KPuzzle> for Phase1Checker {
assert_eq!(orbit_info.name.0, "WEDGES");

for slot in SLOTS_THAT_ARE_AFTER_SLICES {
let value = unsafe {
pattern
.packed_orbit_data()
.get_raw_piece_or_permutation_value(orbit_info, slot)
};
let value = pattern.get_piece(orbit_info, slot);

// TODO: consider removing this lookup. We know that the wedge values are only 0, 1, or
// 2 during this phase.
Expand Down
Loading

0 comments on commit c27ee05

Please sign in to comment.