Skip to content

Commit

Permalink
FREEZE.indexed
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarron committed Aug 21, 2023
1 parent 5a4a883 commit d9e3ce8
Showing 1 changed file with 34 additions and 59 deletions.
93 changes: 34 additions & 59 deletions src/rs/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ mod search;
mod serialize;
mod serve;

use std::process::exit;
use std::{process::exit, time::Instant};

use cubing::{alg::Move, parse_alg, puzzles::cube3x3x3_kpuzzle};
use search::main_search;
use serve::serve;

Expand All @@ -27,64 +28,38 @@ pub mod rust_api {
}

fn main() {
let args = get_options();

let result = match args.command {
options::Command::Completions(_completions_args) => {
panic!("Completions should have been printed during options parsing, followed by program exit.");
}
options::Command::Search(search_command_args) => main_search(
&search_command_args,
&search_command_args
.input_args
.def_file_wrapper_args
.def_file,
&search_command_args.input_args.scramble_file,
search_command_args
.input_args
.def_file_wrapper_args
.debug_print_serialized_json,
&search_command_args.input_args.experimental_target_pattern,
),
options::Command::Serve(serve_command_args) => serve(serve_command_args),
// TODO: consolidate def-only arg implementations.
options::Command::SchreierSims(schreier_sims_command_args) => {
println!("Warning: `schreier-sims` does not support searching with identical pieces. If there are any identical pieces, they will be treated as distinguishable.");

main_search(
&schreier_sims_command_args,
&schreier_sims_command_args.input_args.def_file,
&None,
schreier_sims_command_args
.input_args
.debug_print_serialized_json,
&None, // TODO: allow custom target pattern?
)
}
options::Command::GodsAlgorithm(gods_algorithm_args) => main_search(
&gods_algorithm_args,
&gods_algorithm_args.input_args.def_file,
&None,
gods_algorithm_args.input_args.debug_print_serialized_json,
&None, // TODO: allow custom target pattern?
),
options::Command::TimingTest(args) => main_search(
&args,
&args.input_args.def_file,
&None,
args.input_args.debug_print_serialized_json,
&None, // TODO: allow custom target pattern?
),
options::Command::CanonicalAlgs(args) => main_search(
&args,
&args.input_args.def_file,
&None,
args.input_args.debug_print_serialized_json,
&None, // TODO: allow custom target pattern?
),
let kpuzzle = cube3x3x3_kpuzzle();
let m = |s: &str| {
kpuzzle
.transformation_from_alg(&parse_alg!("R").unwrap())
.unwrap()
};
if let Err(err) = result {
eprintln!("{}", err);
exit(1);
let move_transformations = vec![
m("U"),
m("U2"),
m("U'"),
m("L"),
m("L2"),
m("L'"),
m("F"),
m("F2"),
m("F'"),
m("R"),
m("R2"),
m("R'"),
m("B"),
m("B2"),
m("B'"),
m("D"),
m("D2"),
m("D'"),
];

let mut state = kpuzzle.start_state();
let start = Instant::now();
for i in 0..1000000 {
state = state.apply_transformation(&move_transformations[i % 18]);
}
let duration = start.elapsed();
println!("Time elapsed: {:?}", duration);
}

0 comments on commit d9e3ce8

Please sign in to comment.