A high-performance C++ implementation of a Rubik's Cube solver using multiple algorithmic approaches and optimized cube representations.
- 3D Array: Traditional 3D representation for intuitive understanding
- 1D Array: Memory-efficient linear representation
- Bitboard: Ultra-compact bit-level representation for performance
- BFS (Breadth-First Search): Guaranteed shortest path solution
- DFS (Depth-First Search): Memory-efficient exploration
- IDA* (Iterative Deepening A*): Optimal solution with heuristics
- IDDFS (Iterative Deepening Depth-First Search): Balance between optimality and memory usage
- Pattern Database: Precomputed heuristics for corner piece positions
- Nibble Array: Compact storage for permutation data
- Permutation Indexing: Efficient state space mapping
- CMake (3.10 or higher)
- C++11 or higher compiler (tested with GCC 15)
- MinGW (if on Windows)
# Clone the repository
git clone https://github.com/sachin9919/Rubics_cube_solver.git
cd Rubics_cube_solver
# Create and navigate to build directory
mkdir build
cd build
# Configure and build
cmake ..
cmake --build .
# Run the solver
./cube.exesrc/
├── cube/ # Cube representations
│ ├── RubiksCube.h/cpp # Base cube interface
│ ├── RubiksCube3dArray.cpp # 3D array representation
│ ├── RubiksCube1dArray.cpp # 1D array representation
│ └── RubiksCubeBitboard.cpp # Bitboard representation
│
├── solver/ # Solving algorithms
│ ├── BFSSolver.h # Breadth-first search
│ ├── DFSSolver.h # Depth-first search
│ ├── IDAStarSolver.h # IDA* with heuristics
│ └── IDDFSSolver.h # Iterative deepening DFS
│
├── PatternDatabase/ # Optimization & heuristics
│ ├── PatternDatabase.h/cpp # Pattern database manager
│ ├── CornerPatternDatabase.h/cpp
│ ├── NibbleArray.h/cpp # Compact data storage
│ ├── PermutationIndexer.h # State space indexing
│ └── math.h/cpp # Math utilities
│
└── main.cpp # Entry point
- Parse Input: Accept a scrambled Rubik's Cube state
- Select Algorithm: Choose from BFS, DFS, IDA*, or IDDFS
- Solve: Compute the optimal or near-optimal solution sequence
- Output: Return the sequence of moves to solve the cube
✅ Multiple cube representations implemented and tested
✅ Generic solver algorithms (DFS, BFS, IDDFS)
✅ IDA* solver with heuristic support
✅ Corner pattern database infrastructure
✅ Permutation indexing system
🚧 Performance benchmarking
🚧 Enhanced heuristics
- Uses precomputed corner piece heuristics
- Employs iterative deepening for memory efficiency
- Achieves optimal solutions within practical time limits
- Corners: 8 pieces × 3 orientations = 24 states per corner
- Edges: 12 pieces × 2 orientations = 24 states per edge
- State Space: ~4.3 × 10¹⁹ possible configurations
- Bitboard representation: Fastest for pure computation
- 1D Array: Best memory/performance balance
- 3D Array: Easiest to understand and debug
- Pattern Database: Enables faster solving with IDA*
Feel free to fork, modify, and enhance this project!
This project is open source. Check LICENSE file for details.
Sachin - Rubik's Cube Solver Development
Happy Cubing! 🎲✨