diff --git a/README.md b/README.md index 4757ac1..9265d77 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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 @@ -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. | \ No newline at end of file +| xcross | Solve an extended CFOP cross. |