A small Java Rubik's Cube toolkit and solver (research / hobby project).
Cube.java— cube model and move implementations (byte[54] sticker representation).CubeSolver.java— depth-limited search / IDDFS solver with simple pruning; phase-1 / phase-2 routines.Main.java— entry point and simple UI integration.CubeUI.java/Drawing.java— Swing UI to view and manipulate the cube; keyboard controls inKeyHandler.java.Move.java,IntStack.java,Heuristic.java— supporting classes and utilities.
-
Compile:
javac -d out *.java -
Run the GUI demo:
java -cp out Main
-
Run with a larger heap (recommended for heavy searches):
java -Xmx2g -cp out Main
- The application will open a window showing the cube.
- Keyboard controls are defined in
KeyHandler.java(single-letter keys apply moves; space starts the solver).
- The solver is CPU- and memory-sensitive. For large searches prefer:
- IDDFS (keep only current path in memory) rather than storing entire frontiers.
- Compact keys for visited-state sets (packed longs or Zobrist 64-bit keys) instead of large arrays or String keys.
- In-place move application + undoMove to avoid frequent allocation.