Skip to content

Commit

Permalink
Fix more warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarron committed Feb 4, 2024
1 parent ff2653c commit 8ed38eb
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/rs/_cli/commands/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub fn benchmark(benchmark_args: &BenchmarkArgs) -> Result<(), CommandError> {
&benchmark_args.generator_args.parse(),
&benchmark_args.metric_args.metric,
false,
false,
)
.expect("Could not get search move cache"); // TODO: automatic error conversion.

Expand Down
1 change: 1 addition & 0 deletions src/rs/_cli/commands/canonical_algs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub fn canonical_algs(args: &CanonicalAlgsArgs) -> Result<(), CommandError> {
&args.generator_args.parse(),
&args.metric_args.metric,
false,
false,
)?;

let canonical_fsm = CanonicalFSM::try_new(search_generators).expect("Expected to work!");
Expand Down
3 changes: 3 additions & 0 deletions src/rs/_internal/canonical_fsm/search_generators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ impl<TPuzzle: GenericPuzzle> SearchGenerators<TPuzzle> {
generators: &Generators,
metric: &MetricEnum,
random_start: bool,
invert_generators: bool, // TODO: hack for God's algorithm calculations
) -> Result<SearchGenerators<TPuzzle>, PuzzleError> {
let identity_transformation = TPuzzle::puzzle_identity_transformation(tpuzzle);

Expand All @@ -111,6 +112,8 @@ impl<TPuzzle: GenericPuzzle> SearchGenerators<TPuzzle> {
}
};

let moves: &Vec<Move> = &moves.iter().map(|r#move| r#move.invert()).collect();

// TODO: actually calculate GCDs
let mut grouped = Vec::<MoveTransformationMultiples<TPuzzle>>::default();
for r#move in moves {
Expand Down
8 changes: 4 additions & 4 deletions src/rs/_internal/gods_algorithm/gods_algorithm_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl GodsAlgorithmSearch {
) -> Result<Self, PuzzleError> {
let depth_to_patterns = vec![];
let search_moves =
SearchGenerators::try_new(&kpuzzle, generators, quantum_metric, false)?;
SearchGenerators::try_new(&kpuzzle, generators, quantum_metric, false, true)?;
let canonical_fsm = CanonicalFSM::try_new(search_moves.clone())?;
Ok(Self {
kpuzzle,
Expand Down Expand Up @@ -141,9 +141,9 @@ impl GodsAlgorithmSearch {
};
for move_info in moves_in_class {
num_tested_at_current_depth += 1;
let new_pattern = queue_item.pattern.apply_transformation(
todo!(), // &move_info.inverse_transformation
);
let new_pattern = queue_item
.pattern
.apply_transformation(&move_info.transformation);
if self.table.pattern_to_depth.get(&new_pattern).is_some() {
continue;
}
Expand Down
9 changes: 7 additions & 2 deletions src/rs/_internal/search/idf_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,13 @@ impl<TPuzzle: GenericPuzzle> IDFSearch<TPuzzle> {
random_start: bool,
min_prune_table_size: Option<usize>,
) -> Result<Self, PuzzleError> {
let search_generators =
SearchGenerators::<TPuzzle>::try_new(&tpuzzle, &generators, metric, random_start)?;
let search_generators = SearchGenerators::<TPuzzle>::try_new(
&tpuzzle,
&generators,
metric,
random_start,
false,
)?;

let canonical_fsm = CanonicalFSM::try_new(search_generators.clone())?; // TODO: avoid a clone

Expand Down
1 change: 1 addition & 0 deletions src/rs/scramble/puzzles/big_cubes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ impl ScrambleInfo {
}),
&crate::_internal::options::MetricEnum::Hand,
false,
false,
)
.unwrap();
let canonical_fsm = CanonicalFSM::try_new(generators.clone()).unwrap();
Expand Down
18 changes: 8 additions & 10 deletions src/rs/scramble/puzzles/cube4x4x4/four_phase.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{collections::HashSet, sync::Arc};

use cubing::{
alg::{parse_alg, parse_move, Alg, AlgBuilder, AlgNode, Pause},
alg::{parse_move, Alg, AlgBuilder, AlgNode, Pause},
kpuzzle::{KPattern, KPuzzle},
};

Expand All @@ -17,7 +17,7 @@ use crate::{
puzzles::{
cube4x4x4::{
phase2::{
pattern_to_phase2_pattern, remap_piece_for_phase1_or_phase2_search_pattern,
remap_piece_for_phase1_or_phase2_search_pattern,
Phase2ReplacementSolutionCondition,
},
phase2_symmetry::Phase2SymmetryTables,
Expand Down Expand Up @@ -163,14 +163,12 @@ impl Scramble4x4x4FourPhase {

// let phase2_search_full_pattern = main_search_pattern.apply_alg(&phase1_alg).unwrap(); // TODO

let phase2_search_pattern =
self.phase2_idfs.api_data.tpuzzle.coordinate_for_pattern(
&phase2_kpuzzle_search_pattern,
// &pattern_to_phase2_pattern(&phase2_kpuzzle_search_pattern),
);
let phase2_search_pattern = self.phase2_idfs.api_data.tpuzzle.coordinate_for_pattern(
&phase2_kpuzzle_search_pattern,
// &pattern_to_phase2_pattern(&phase2_kpuzzle_search_pattern),
);

let mut individual_search_options = IndividualSearchOptions::default();
individual_search_options.phase2_debug = false;
let individual_search_options = IndividualSearchOptions::default();
let solution_condition = Phase2ReplacementSolutionCondition {
checked_patterns_coord: HashSet::default(),
checked_patterns_full: HashSet::default(),
Expand Down Expand Up @@ -220,7 +218,7 @@ impl Scramble4x4x4FourPhase {

pub(crate) fn scramble_4x4x4(&mut self) -> Alg {
loop {
let hardcoded_scramble_alg_for_testing = parse_alg!("F' R' B2 D L' B D L2 F L2 F2 B' L2 U2 F2 U2 F' R2 L2 D' L2 Fw2 Rw2 R F' Uw2 U2 Fw2 F Uw2 L U2 R2 D2 Uw U F R F' Rw' Fw B Uw' L' Fw2 F2");
// let hardcoded_scramble_alg_for_testing = parse_alg!("F' R' B2 D L' B D L2 F L2 F2 B' L2 U2 F2 U2 F' R2 L2 D' L2 Fw2 Rw2 R F' Uw2 U2 Fw2 F Uw2 L U2 R2 D2 Uw U F R F' Rw' Fw B Uw' L' Fw2 F2");
// let hardcoded_scramble_alg_for_testing = parse_alg!("2R u");
// let hardcoded_scramble_alg_for_testing =
// parse_alg!("r U2 x r U2 r U2 r' U2 l U2 r' U2 r U2 r' U2 r'");
Expand Down
5 changes: 3 additions & 2 deletions src/rs/scramble/puzzles/cube4x4x4/phase2_symmetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ impl Coord for CoordEP {
r += cyclen + 1;
}
}
if (sum != 276) {
if sum != 276 {
panic!("Coord for coordep called on bad kpuzzle type");
}
Phase2Coordinate(r & 1)
Expand Down Expand Up @@ -413,7 +413,7 @@ pub(crate) struct Phase2Puzzle {

impl Phase2Puzzle {
pub(crate) fn coordinate_for_pattern(&self, pattern: &KPattern) -> Phase2CoordTuple {
let phase2_pattern = pattern_to_phase2_pattern(&pattern);
let phase2_pattern = pattern_to_phase2_pattern(pattern);
Phase2CoordTuple {
c84: self.data.coord_84.coordinate_for_pattern(&phase2_pattern),
c168: self.data.coord_168.coordinate_for_pattern(&phase2_pattern),
Expand Down Expand Up @@ -616,6 +616,7 @@ impl Phase2SymmetryTables {
&phase2_generators,
&MetricEnum::Hand,
false,
false,
) {
Result::Ok(search_generators) => {
self.fill_move_table(
Expand Down

0 comments on commit 8ed38eb

Please sign in to comment.