Skip to content

Commit

Permalink
update: README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
luckasRanarison committed Nov 6, 2023
1 parent 6efa188 commit f7ae470
Showing 1 changed file with 31 additions and 19 deletions.
50 changes: 31 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,31 @@
[![Build/test](https://github.com/luckasRanarison/kewb/actions/workflows/rust.yml/badge.svg)](https://github.com/luckasRanarison/kewb/actions/workflows/rust.yml)
[![crates.io](https://img.shields.io/crates/v/kewb)](https://crates.io/crates/kewb)

This is a Rubik's cube solver that uses Kociemba's [two-phase algorithm](http://kociemba.org/cube.htm) 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.
Kewb is a library for manipulating and solving the 3x3 Rubiks's cube using Kociemba's [two-phase algorithm](http://kociemba.org/cube.htm). There is also a [CLI](#cli) version which showcases most of kewb features.

## 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](https://www.cube20.org/).
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.

```bash
kewb-cli help
kewb-cli solve --scramble "R U R' U'" --max 22 --timeout 1 --details
kewb-cli solve -s "R U R' U'" -m 22 -t 1 -d
# default values: max = 23, timeout = none, details = false
kewb-cli scramble
kewb-cli scramble -n 5
# default values: number = 1
kewb-cli solve --facelet DRBLUURLDRBLRRBFLFFUBFFDRUDURRBDFBBULDUDLUDLBUFFDBFLRL
```
## Usage

### Library

https://docs.rs/kewb/latest/kewb/
See https://docs.rs/kewb/latest/kewb/ for an exhaustive list of APIs provided by kewb.

The solver needs some precomputed data which is represented by the `DataTable` struct. However, generating it takes some amount of time so it's recommended to write it on the disk or bundle it with the executable. You can also use the `table` command from `kewb-cli` to generate the table.

```rust
use kewb::{error::Error, utils::scramble_from_string, DataTable, FaceCube, Solver, State};


fn main() -> Result<(), Error> {
// Generating the table takes some time so it's recommended to write it on the disk
// write_table("path_to_file")?;
// Method 1: Bundling the table in the executable
// const TABLE_BYTES = include_bytes!("./path_to_file")
// let table = decode_table(&TABLE_BYTES)?;

// Method 2: Reading the table from a file
// let table = read_table("./path_to_file")?;

// Method 3: Generating the table at runtime (slow)
let table = DataTable::default();

let mut solver = Solver::new(&table, 23, None);
Expand All @@ -53,6 +48,23 @@ fn main() -> Result<(), Error> {
}
```

### 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](https://www.cube20.org/).

```bash
kewb-cli help
# default values: max = 23, timeout = none, details = false
kewb-cli solve --scramble "R U R' U'" --max 22 --timeout 1 --details
kewb-cli solve -s "R U R' U'" -m 22 -t 1 -d
kewb-cli solve --facelet DRBLUURLDRBLRRBFLFFUBFFDRUDURRBDFBBULDUDLUDLBUFFDBFLRL
# default values: number = 1, preview = false
kewb-cli scramble -p
kewb-cli scramble -n 5
# generates the table used by the solver
kewb-cli table ./path_to_file
```

## Build

**NB: You must have the rust toolchain installed**
Expand Down

0 comments on commit f7ae470

Please sign in to comment.