Expand description
A simple Rubik’s Cube simulator (and eventually solver).
§Quick Start Guide
To quickly get a Rubik’s Cube simulation running, we can follow the code sample below:
use cubesim::prelude::{Cube, Move, MoveVariant};
use cubesim::FaceletCube;
let cube = FaceletCube::new(3);
let turned_cube = cube.apply_move(Move::U(MoveVariant::Double));
println!("{:?}", turned_cube.state());
§Cube Trait Overview
To support multiple underlying implementations of a Rubik’s Cube, we define a Cube
trait
which define the minimal set of behaviours expected of a Rubik’s Cube. Specific implementations
can then be used for different scenarios that fit its characteristics. For example, the FaceletCube
is the most performant and versatile while the GeoCube
allows for easy 3D modelling.
Structs§
- Facelet
Cube - A Rubik’s Cube with stickers stored sequentially in a 1-dimensional array.
- GeoCube
- A Rubik’s Cube with each of its facelets represented as a Sticker.
- Pruning
Table - A Pruning Table giving a lower bound for the number of moves to solve a specific state.
- Solver
- A combination of a Pruning Table and the candidate moves to solve into a specific state.
Enums§
- Face
- A face of a Rubik’s Cube sticker represented in WCA notation.
- Move
- A move of a NxNxN Rubik’s Cube represented in WCA notation.
- Move
Variant - A move variation that must be applied to the
Move
struct.
Traits§
- Cube
- A Rubik’s Cube of arbitrary size.
Functions§
- all_
moves - Get all possible moves for a cube of a given size.
- parse_
scramble - Converts a WCA Notation scramble into
Vec<Move>
. - simplify_
moves - Merges all related adjacent moves in a sequence of moves.
- solve
- Solves a 3x3x3 Cube using the Thistlethwaite Algorithm.
- solved_
state - Get the solved state for a cube of a given size.
- sticker_
index - Get the index of a specific piece on a specific face.