Skip to content

Commit

Permalink
Adjust initialization.
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarron committed Jan 26, 2024
1 parent 86c2fc6 commit a781ec5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
14 changes: 7 additions & 7 deletions src/rs/scramble/puzzles/cube4x4x4/four_phase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ use crate::{
},
};

use super::super::super::scramble_search::generators_from_vec_str;
use super::{
super::super::scramble_search::generators_from_vec_str, phase2_symmetry::Phase2Puzzle,
};

pub(crate) struct Scramble4x4x4FourPhase {
kpuzzle: KPuzzle,
Expand All @@ -36,7 +38,7 @@ pub(crate) struct Scramble4x4x4FourPhase {
phase1_target_pattern: KPattern,
phase1_idfs: IDFSearch<KPuzzle>,

phase2_idfs: IDFSearch<KPuzzle>,
phase2_idfs: IDFSearch<Phase2Puzzle>,
}

impl Default for Scramble4x4x4FourPhase {
Expand All @@ -59,12 +61,14 @@ impl Default for Scramble4x4x4FourPhase {
None,
);

let phase2_symmetry_tables = Phase2SymmetryTables::new();

let phase2_generators =
generators_from_vec_str(vec!["Uw2", "U", "L", "F", "Rw", "R", "B", "Dw2", "D"]);
let phase2_center_target_pattern = cube4x4x4_phase2_target_kpattern();
// dbg!(&phase2_center_target_pattern);
let phase2_idfs = idfs_with_target_pattern(
phase2_kpuzzle,
phase2_symmetry_tables.puzzle,
phase2_generators.clone(),
phase2_center_target_pattern.clone(),
None,
Expand All @@ -85,10 +89,6 @@ impl Scramble4x4x4FourPhase {
&mut self,
main_search_pattern: &KPattern, // TODO: avoid assuming a superpattern.
) -> Alg {
let mut x = Phase2SymmetryTables::new(self.kpuzzle.clone());
x.init_choose_tables();
x.init_move_tables();
x.init_prune_table();
let phase1_alg = {
let mut phase1_search_pattern = self.phase1_target_pattern.clone();
for orbit_info in self.kpuzzle.orbit_info_iter() {
Expand Down
18 changes: 9 additions & 9 deletions src/rs/scramble/puzzles/cube4x4x4/phase2_symmetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
PruneTableEntryType, SearchGenerators,
},
scramble::puzzles::definitions::{
cube4x4x4_kpuzzle, cube4x4x4_phase2_target_kpattern, cube4x4x4_with_wing_parity_kpuzzle,
cube4x4x4_phase2_target_kpattern, cube4x4x4_with_wing_parity_kpuzzle,
},
};

Expand All @@ -17,7 +17,6 @@ use cubing::{
};

use super::{
super::super::scramble_search::generators_from_vec_str,
orbit_info::orbit_info,
phase2::{SideCenter, PHASE2_SOLVED_SIDE_CENTER_CASES},
};
Expand Down Expand Up @@ -263,7 +262,7 @@ fn pack_coords(c84: Phase2Coordinate, c168: Phase2Coordinate, ep: Phase2Coordina
struct Phase2IndexedMove(pub usize);

#[derive(Debug)]
struct Phase2Puzzle {
pub(crate) struct Phase2Puzzle {
search_generators: SearchGenerators<Self>,
move_to_transformation: HashMap<Move, Phase2IndexedMove>,
coord_84: Coord84,
Expand Down Expand Up @@ -378,17 +377,19 @@ impl GenericPuzzleCore for Phase2Puzzle {

pub(crate) struct Phase2SymmetryTables {
phase2_puzzle: Phase2Puzzle,
kpuzzle: KPuzzle, // TODO: is this needed?
phase2_prune_table: [PruneTableEntryType; PHASE2_PRUNE_TABLE_SIZE],
}

impl Phase2SymmetryTables {
pub(crate) fn new(kpuzzle: KPuzzle) -> Self {
Self {
pub(crate) fn new() -> Self {
let mut phase2_symmetry_tables = Self {
phase2_puzzle: Phase2Puzzle::new(),
kpuzzle,
phase2_prune_table: [PRUNE_TABLE_UNINITIALIZED_VALUE; PHASE2_PRUNE_TABLE_SIZE],
}
};
phase2_symmetry_tables.init_choose_tables();
phase2_symmetry_tables.init_move_tables();
phase2_symmetry_tables.init_prune_table();
phase2_symmetry_tables
}

pub(crate) fn init_choose_tables(&mut self) {
Expand Down Expand Up @@ -483,7 +484,6 @@ impl Phase2SymmetryTables {
}

pub(crate) fn init_move_tables(&mut self) {
self.kpuzzle = cube4x4x4_kpuzzle().clone();
let phase2_generators = Generators::Custom(CustomGenerators {
moves: self
.phase2_puzzle
Expand Down

0 comments on commit a781ec5

Please sign in to comment.