This project implements a Rubik's Cube solver using various search algorithms including DFS, BFS, IDDFS (Iterative Deepening Depth-First Search), and IDA* (Iterative Deepening A*). The cube state is represented using three different implementations for performance comparison: 3D array, 1D array, and bitboard representation.
- Multiple Rubik's Cube representations:
- 3D Array representation
- 1D Array representation
- Bitboard representation
- Various solving algorithms:
- Depth-First Search (DFS)
- Breadth-First Search (BFS)
- Iterative Deepening DFS (IDDFS)
- Iterative Deepening A* (IDA*)
- Pattern database for heuristic-based solving
- Support for all standard Rubik's Cube moves (F, F', F2, B, B', B2, etc.)
- CMake (version 3.0 or higher)
- C++ compiler with C++11 support
- Make
-
Clone the repository:
git clone https://github.com/yourusername/rubiks-cube-solver.git cd rubiks-cube-solver -
Create a build directory and navigate to it:
mkdir build cd build -
Generate the build files using CMake:
cmake ..
-
Build the project:
make
-
Create the database directory:
mkdir -p ../Databases
After building, you can run the solver from the build directory:
./rubiks_cube_solverThe program will:
- Create a new Rubik's cube
- Apply random moves to shuffle it
- Solve the cube using the IDA* algorithm
- Display both the scrambled and solved states
Rubik's Cube:
W Y R
W W R
R R R
G G G Y G Y O B B W R O
G G O W R W R B B W O O
O O W R G G Y B B W B B
G Y O
Y Y B
Y Y O
Scramble: D R2 L' U' R2 L2 R R L' F F2 F R'
Solution: R L' U L R2 D'
Model/: Contains different Rubik's Cube representationsRubiksCube.h: Base class for all representationsRubiksCube3dArray.h: 3D array implementationRubiksCube1dArray.h: 1D array implementationRubiksCubeBitboard.h: Bitboard implementation
Solver/: Contains different solving algorithmsDFSSolver.h: Depth-First Search solverBFSSolver.h: Breadth-First Search solverIDDFSSolver.h: Iterative Deepening DFS solverIDAstarSolver.h: IDA* solver
PatternDatabases/: Pattern database implementation for heuristic-based solving
Feel free to open issues or submit pull requests if you have any improvements or bug fixes.
This project is licensed under the MIT License - see the LICENSE file for details.