Kewb

Build/test crates.io

This is a Rubik's cube solver that uses Kociemba's two-phase algorithm and can also be used as a library for manipulating the 3x3 Rubik's cube. However, please note that this is still a work in progress and the implementation is not yet efficient. The solver does not currently use symmetric reductions, pre-moves, or multi-threaded search.

Usage

CLI

By default, there is no timeout, which means the solver will return the first solution it finds. However, by adding a timeout, the solver will continue searching until the timeout has elapsed and return the shortest solution found or nothing. Specifying a lower search depth can result in better solution quality (around 21 to 23 moves), but it can also make the search slower if the depth is less than 20 moves. Nevertheless, it has been proven that all cases can be solved in 20 moves or fewer.

```bash kewb help kewb solve --scramble "R U R' U'" --max 22 --timeout 1 --details kewb solve -s "R U R' U'" -m 22 -t 1 -d

default values: max = 23, timeout = none, details = false

kewb scramble kewb scramble -n 5

default values: number = 1

kewb solve --facelet DRBLUURLDRBLRRBFLFFUBFFDRUDURRBDFBBULDUDLUDLBUFFDBFLRL ```

Library

```rust use std::io; use kewb::{ solve, Solver, State, FaceCube, fs::readtable, utils::scramblefrom_string, };

fn main() -> Result<(), io::Error> { let scramble = scramblefromstring("R U R' U'").unwrap(); let state = State::from(&scramble); let solution = solve(state, 23, None).unwrap();

println!("{}", solution);

let faces = "DRBLUURLDRBLRRBFLFFUBFFDRUDURRBDFBBULDUDLUDLBUFFDBFLRL";
let face_cube = FaceCube::try_from(faces).unwrap();
let state = State::try_from(&face_cube).unwrap();
let (move_table, pruning_table) = read_table()?;
let mut solver = Solver::new(&move_table, &pruning_table, 23, None);
let solution = solver.solve(state).unwrap();

println!("{}", solution);

Ok(())

} ```

Build

NB: You must have the rust toolchain installed

Clone the repository and run:

```bash cargo build --release # build in target/build/

or

cargo install --path . # install to ~/.cargo/bin/ ```

Testing

You can run the tests by running:

bash cargo test

Todo

References