A native 3D Rubik's cube playground, written in Mojo 1.0.
Rounded pieces, studio lighting, animated layer turns, and a computer that brings all six colors back into order. No browser, JavaScript, TypeScript, Python game code, web server, or Python solver.
Requires Linux x86-64, a graphical desktop with OpenGL 3.3 support and X11/XWayland, and Pixi. Tested on CachyOS with Intel Arc graphics.
git clone --recurse-submodules https://github.com/wmostert76/mojo-cube.git
cd mojo-cube
pixi run startPixi installs Mojo 1.0.0 and builds the pinned graphics bindings on the first run. Later starts reuse those dependencies. To restore submodules after a plain clone:
git submodule update --init --recursiveThe window resizes normally. Use its controls to switch between 2×2 and 7×7, change lighting, spread the pieces apart, scramble, turn outer or inner slices, and solve. Playback supports pause, single-step and adjustable speed.
| Control | Action |
|---|---|
| Drag the scene / mouse wheel | Orbit / zoom |
| U, L, F, R, B, D | Turn that face clockwise |
| Shift + face key | Turn counterclockwise |
| 2–7 | Start a fresh cube of that size |
| S / Enter | Scramble / solve |
| Space / Right arrow | Pause or resume / step one turn |
| Z | Undo the previous recorded turn |
| Home | Center the camera |
| F1 / F11 | Help / fullscreen |
| F12 | Save a screenshot to docs/screenshot.png |
| Escape | Close help, or exit the game |
Completed moves are saved locally in chroma.save. Closing halfway through a
turn restores the last completed, exact cube state on the next launch. Changing
size or resetting starts a new puzzle. Settings and elapsed time are per session.
All application code, including the engine, solver, UI, geometry, lighting,
input handling, animation, persistence and tests, is .mojo source.
The game calls the third-party raylib 6 graphics library through mojo-raylib. Raylib and the bindings' ABI shim are written in C. They provide the native window, device input, fonts and OpenGL draw calls; they do not implement this game's cube or solver. The Mojo toolchain may install Python-related packaging components. The built application does not import Python or load a Python interpreter.
Lighting is calculated in Mojo per vertex: three colored studio lights, diffuse shading, specular highlights and an edge reflection term. The rounded meshes and soft radial stage gradients are also generated in Mojo, then drawn by OpenGL. There are no application-authored GLSL shaders.
The solver reads only the current face colors. It receives no scramble, move history or undo journal, and cannot replay them backwards. All solving runs natively in Mojo using constructive NxN algorithms adapted from ShellPuppy/RCube:
- Align and solve centers with legal commutator sequences (3×3 and larger).
- Place and orient the eight corners.
- Pair and orient edges, including even-size parity cases.
- Combine commuting slice turns and verify the complete result before animation.
The algorithms support legal 2×2 through 7×7 states, including inner-slice turns. Tests rebuild cubes from detached face colors to verify independence from both history and original sticker identity. There is no Python or C solver fallback.
This is a constructive solver, not a shortest-solution search. Large cubes can need thousands of turns; playback supports up to 32× speed, pause and single-step. The game does not currently provide a facelet editor or validate impossible, manually painted cubes. The move journal is used only for undo and save/restore.
pixi run test
pixi run build
pixi run ./build/chroma --smoke-test
# Optional full 7x7 graphical solve:
pixi run ./build/chroma --smoke-largeThe unit checks cover every layer of every supported size, inverse/four-turn
identities, random mixed-layer scrambles and manual turns, verified solutions,
240 additional long random states reconstructed from face colors, pause/step/undo,
commuting simplification and persistence. The graphical smoke
test opens a real window, scrambles, solves and checks the final state. It writes
screenshots into docs/ and requires a working graphical display.
See development notes for the library APIs and architecture.
The combined application is licensed under GPL-3.0-only, including the Mojo adaptation of RCube's solving algorithms. See third-party notices for upstream revisions, retained notices and the original application MIT grant. Mojo is developed by Modular. mojo-raylib by KiviCode and raylib by Ramon Santamaria and contributors retain their zlib-style licenses in the pinned submodules. Space Grotesk is distributed under the SIL Open Font License.
This is an independent cube puzzle project, not an official Rubik's product.
