Skip to content

Commit

Permalink
chore: Update README to document pre-moves
Browse files Browse the repository at this point in the history
  • Loading branch information
torjusti committed Dec 26, 2019
1 parent bb66d8a commit b5fad09
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This module contains a collection of Rubik's cube solvers implemented in JavaScr

To install, simply run `yarn install cube-solver` or similar, and require the `cube-solver` module. You can also manually add the bundle file to your webpage using [this unpkg link](https://unpkg.com/cube-solver/dist/bundle.js), in which case the solver will be available globally as `cubeSolver`.

## Example
## Examples

```javascript
// Get a new random-state scramble.
Expand All @@ -22,11 +22,23 @@ cubeSolver.scramble('zbll'); // => R B2 R' U' L U' L U' F2 R2 U' B2 U R2 D' F2 U

## Notes

The solver is pretty slow compared to other solvers such as the GWT compiled version of min2phase, but rather aims to be simple and extensible. The Kociemba solver initializes when solving the first cube, which usually takes around 2 seconds. Generating and solving a random cube takes around 100ms on average, but for some cubes this number can be quite high. The optimal EOLine, FB, Cross and XCross solvers initialize pretty quickly, with the exception of the XCross solver.
The full 3x3 solver is pretty slow compared to other solvers such as the GWT compiled version of min2phase - it rather aims to be simple and extensible. Unless explicitly initialized, the Kociemba solver initializes when solving the first cube, which usually takes around 2 seconds. Generating and solving a random cube takes around 100ms on average, but for some cubes this number can be quite high. The optimal EOLine, FB, Cross and XCross solvers initialize pretty quickly, with the exception of the XCross solver which also takes around 2 seconds. *As a consequence, you probably want to use this library in conjunction with web workers.*

## Documentation

The solver exposes three methods. The first,`cubeSolver.scramble(type = '3x3')`, allows for scrambling the cube or different subsets of it, and `cubeSolver.solve(scramble, type = 'kociemba')` allows for solving the cube or different subsets of it. Solvers are initialized on the first solve, but you can manually initialize them by calling `cubeSolver.initialize(solver)`. See below for a list of available solver types.
The solver exposes three main methods.

- `cubeSolver.scramble(type = '3x3')` lets you generate scrambles for the entire cube or subsets of it --- see below for a list of available scramblers.
- `cubeSolver.solve(scramble, type = 'kociemba')` lets you solve either the entire cube or a subset of it for a given scramble. See below for a list of available solvers.
- `cubeSolver.initialize(solver)` lets you initialize solvers so that the first solve is quicker. See below for a list of available solvers. To speed up random-state *scrambles*, the Kociemba solver should be initialized.

In general, the solvers will put the feature being solved for on the *bottom*. For example, using normal orientation, solving for an XCross will yield a yellow cross with the front-left pair solved. To solve other positions, you can apply pre-moves to your scrambles. This example shows how to find a bottom-left yellow XCross:

```javascript
const scramble = `U2 B2 D R' F R2 U2 L D R2 L2 F2 U R2 U' L2 D F2 R2`;
// Find an optimal solution for cross + the back left pair.
cubeSolver.solve(`y ${scramble}`); // => U L2 F' R' F' D L' D
```

### Available scramble types

Expand All @@ -51,4 +63,4 @@ The solver exposes three methods. The first,`cubeSolver.scramble(type = '3x3')`,
| cross | Solve the CFOP cross. |
| eoline | Solve the ZZ EOLine. |
| fb | Solve the Roux first block, on the bottom left. |
| xcross | Solve an extended CFOP cross. |
| xcross | Solve an extended CFOP cross. |

0 comments on commit b5fad09

Please sign in to comment.