| Crates.io | rubiks-cube-representation |
| lib.rs | rubiks-cube-representation |
| version | 0.1.0 |
| created_at | 2025-10-02 00:27:31.779473+00 |
| updated_at | 2025-10-02 00:27:31.779473+00 |
| description | A mathematical library for representing and analyzing Rubik's cubes using group theory and tile permutations |
| homepage | |
| repository | https://github.com/HaineSensei/rubiks-cube-representation |
| max_upload_size | |
| id | 1863689 |
| size | 247,500 |
A Rust library for representing and analyzing Rubik's cubes using group theory and tile permutations.
* operator syntaxRubiksState<N>: Complete state of an N×N×N cubeTilePos: Position of an individual tile (face, row, col)TilePerm<N>: Permutation of all 6N² tiles on a cubeCubeRotation: Whole-cube rotations (X, Y, Z and variants)BasicMove<N>: Standard face turns (U, D, L, R, F, B with 2/3 variants)WideMove<N>: Multi-layer turns (Uw, Dw, etc.)SliceMove<N>: Single internal layer moves (Us, Ds, etc.)RangeMove<N>: Layer range moves (Ur, Dr, etc.)MiddleMove<N>: Traditional middle slice moves (M, E, S)ColourScheme: Trait for different color schemesWestern: Standard Western color scheme (white opposite yellow, etc.)Japanese: Japanese color scheme variantuse rubiks_cube_representation::*;
use rubiks_cube_representation::core::cube::schemes::Western;
use rubiks_cube_representation::core::cube::rotations::Y;
use rubiks_cube_representation::core::rubiks::moves::BasicMove;
// Create a solved 3×3×3 cube in Western colors
let cube = RubiksState::<3>::solved_in(Western);
// Apply a U move
let cube_after_u = &cube * &BasicMove::<3>::U;
// Compose operations algebraically
let cube_rotated = &cube * &Y * &BasicMove::<3>::R * &BasicMove::<3>::U;
// Check solving state
assert!(cube.is_solved_in(Western));
assert!(cube.is_solved_up_to_rotation_in(Western));
use rubiks_cube_representation::core::rubiks::tiles::TilePerm;
use rubiks_cube_representation::core::rubiks::moves::BasicMove;
use rubiks_cube_representation::core::cube::rotations::X;
// Convert operations to tile permutations
let u_perm = TilePerm::<3>::from(&BasicMove::<3>::U);
let x_perm = TilePerm::<3>::from(&X);
// Compose permutations
let combined = &u_perm * &x_perm * &u_perm;
// Compute inverse
let inverse = combined.inverse();
assert_eq!(&combined * &inverse, TilePerm::<3>::ID);
use rubiks_cube_representation::*;
use rubiks_cube_representation::core::cube::schemes::Western;
use rubiks_cube_representation::core::rubiks::moves::{WideMove, MiddleMove};
// Create a 5×5×5 cube
let cube_5x5 = RubiksState::<5>::solved_in(Western);
// Wide moves work on any dimension
let after_wide = &cube_5x5 * &WideMove::<5>::Uw(3);
// Middle moves adjust to cube size (N/2 for odd N)
let after_middle = &cube_5x5 * &MiddleMove::<5>::M;
This library uses a group-theoretic approach to cube representation:
core::cube) vs concrete implementation (core::rubiks)The mathematical foundation is complete with a fully tested tile permutation system. All standard move types are implemented and verified to agree with cube rotations on their respective slices.
Implemented:
* operatorFuture directions:
This project is a collaboration between HaineSensei and Claude (Anthropic's AI assistant).
HaineSensei designed and implemented all mathematical foundations, core algorithms, and system architecture. This includes the group-theoretic approach, tile permutation system, geometric algorithms, and type system design.
Claude provided comprehensive documentation (including this README.md), test suite development, and supporting tasks like code restructuring and bug identification.
This division ensures deep understanding of all complex logic remains with the human developer, while AI assistance accelerates the tedious but essential work of documentation and testing.
Japanese_colors.webp and Western_colors.webp are from here