Crate cubesim[][src]

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.


A Rubik’s Cube with stickers stored sequentially in a 1-dimensional array.

A Rubik’s Cube with each of its facelets represented as a Sticker.

A Pruning Table giving a lower bound for the number of moves to solve a specific state.

A combination of a Pruning Table and the candidate moves to solve into a specific state.


A face of a Rubik’s Cube sticker represented in WCA notation.

A move of a NxNxN Rubik’s Cube represented in WCA notation.

A move variation that must be applied to the Move struct.


A Rubik’s Cube of arbitrary size.


Get all possible moves for a cube of a given size.

Converts a WCA Notation scramble into Vec<Move>.

Merges all related adjacent moves in a sequence of moves.

Solves a 3x3x3 Cube using the Thistlethwaite Algorithm.

Get the solved state for a cube of a given size.

Get the index of a specific piece on a specific face.