Skip to content

MikeCroall/rusty-puzzle-cube

Repository files navigation

Rusty Puzzle Cube

An experimental implementation of simple puzzle cubes in Rust

rust-ci lib coverage ui coverage brainmade.org

Puzzle Cube GUI Crate

Still a work in progress. Screenshots and/or demo gif may not be fully up to date with the latest features.

Demo video

Cube in Cube in Cube 3D 4x4x4 screenshot

Shuffled 3D 10x10x10 screenshot

Known transforms dropdown screenshot

Controls

Click and drag along a line of cubies to perform a rotation, making sure to remain on the face the drag started on

Shuffle will make 10n random moves on an n x n x n cube

Some controls (debug) are removed on the WASM target

Building Puzzle Cube GUI Crate for web

Build command written from inside the web dir, with the RUSTFLAGS required since rand 0.9

RUSTFLAGS='--cfg getrandom_backend="wasm_js"' npx wasm-pack build "../puzzle-cube-ui" --target web --out-name web --out-dir ../web/pkg

Files built into web/pkg/, which can be hosted by

npm run serve

Then visit http://localhost:8080

Puzzle Cube Lib Crate Demo

Demos of known transforms and basic notation being parsed and applied to a newly created cube

Notation Parsed: Cube in Cube in Cube

Also available as KnownTransform::NestedCube3x3x3

let mut cube = Cube::create(3.try_into()?);
let notation = "F R' U' F' U L' B U' B2 U' F' R' B R2 F U L U";
perform_notation(notation, &mut cube)?;
print!("{cube}");

Cube in Cube in Cube output screenshot

Known Transform: Checkerboard Corners

let mut cube = Cube::create(3.try_into()?);
KnownTransform::CheckerboardCorners3x3x3.perform_instantly(&mut cube);
print!("{cube}");

Checkerboard Corners output screenshot

Unique Cubies and Large Cubes

Large cubes can be created by providing a larger side length, and cubies can each be given a unique character to keep track of exactly where they move as moves are applied

Note that side length is limited to a maximum of 8 when using unique characters to avoid leaving the basic ASCII range (and trying to use the DEL control code in a cubie)

let mut cube = Cube::create_with_unique_characters(8.try_into()?);
print!("{cube}");

Big Cube and Unique Cubie output screenshot

About

An experimental implementation of simple puzzle cubes in Rust

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages