A fully implemented Rubik's Cube that allows you to make all possible moves with the functionality of solving the Rubik's Cube using the IDA* (Iterative Deepening A Star) algorithm and DFS (Depth First Search).
Cube solver created using the IDA* (Iterative Deepening A Star) algorithm involving DFS (Depth First Search), heuristic value calculation (using the Manhattan Distance) and optimized using pruning techniques such as preventing the algorithm from iterating over the same cube state again.
Graphics implemented using OpenGL.
![Screenshot 2024-03-17 at 5 37 20 PM](https://private-user-images.githubusercontent.com/86296165/313563604-80c9c474-bff0-4d90-a1ec-457727b8f134.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQwNDk4NjQsIm5iZiI6MTcyNDA0OTU2NCwicGF0aCI6Ii84NjI5NjE2NS8zMTM1NjM2MDQtODBjOWM0NzQtYmZmMC00ZDkwLWExZWMtNDU3NzI3YjhmMTM0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE5VDA2MzkyNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTkwZjdmNjlkNjBlOTRkYWFmNmZmMzE4NDA5NzhmZjI0YjM0MjcyZTE4MGYyNzViNDQzMTcxNDhlYTU1ZDI2YzYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.HXpUWGjrm3YxrSXonc10ECSIQ4O_hpO5shhvhEhBJDg)
- Solves the Rubik's Cube extremely fast using the IDA* algorithm coupled with DFS and displays all the moves required to reach the solution
- Heuristic value generated using the Manhattan Distance for accurate results and preventing overestimation
- Optimized by adding functionality such as preventing iteration over the same cube state again
- Ability to make custom moves on the Rubik's Cube
- Visually appealing Rubik's Cube graphics implemented using OpenGL
- Fully implemented Rubik's Cube with instant change in cube graphics when making a move
This project was created in C++ (3.17) in the CLion IDE.
I implemented the Rubik's Cube using the standard OOP's techniques. A class 'Cube' represents the cube in which all the movement, solving algorithms and initialization methods are present. The class 'Pieces' is the parent class of all the pieces in a Rubik's Cube. I stored the various Rubik's Cube pieces as classes - CornerPiece, EdgePiece and CentrePiece. Each of these classes store the colour of each edge and its orientation. The 'Side' class represents the side of a Rubik's Cube and has vector attributes that stores the corner pieces, edge pieces and the center pieces. The 'Colour' class is used to store the RGB colour data and the colour name.
The 'main' file is where the program runs and the graphics are implemented using OpenGL.
The project has been structured in the traditional C++ style with header and cpp files being separate for readability.
![Screenshot 2024-03-26 at 11 10 36 PM](https://private-user-images.githubusercontent.com/86296165/317111134-e32ef818-b45e-4f1c-8ca4-7d7603ecf519.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQwNDk4NjQsIm5iZiI6MTcyNDA0OTU2NCwicGF0aCI6Ii84NjI5NjE2NS8zMTcxMTExMzQtZTMyZWY4MTgtYjQ1ZS00ZjFjLThjYTQtN2Q3NjAzZWNmNTE5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE5VDA2MzkyNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFlY2I2ZmI2MjRmZGMwY2JhYzc4OGQwNTI5YTVlMDMzMTA4ZjNjNzRkYTNkYTM2OTExZDM2MGRkMzRhMmVjMTkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.JMBQ1s7dON4tN_R4PWMxfxZXxcx5jMuZA4ScweinZnk)
The program can be run on any normal laptop. To use the project, you can use any IDE that supports C++ (3.17).
To use this, you will need C++ and any IDE that runs C++. You will first need to install OpenGL using Homebrew (use any online tutorial to learn how to install OpenGL using Homebrew). You might need to change some file locations depending on where your OpenGL package is saved in the CMakeLists.txt file.
To use this program, you must run the 'main' file. Once done, the OpenGL window should pop up and you should see a solved Rubik's Cube spinning. In the console, you can type various commands to perform operations on the cube. You can type something like 'white R' to perform the R move on the cube facing the white side. Similarly, you can type 'orange FI' to perform the inverse of the F move on the cube facing the orange side. You will see the cube update based on your command. You can continue typing these commands or you can type 'scramble'. This will randomly scramble the cube. You can then type 'solve' to solve the cube.
The program can be terminated directly from the IDE.
I worked on this project alone and will not be actively working on the project anymore (I will be creating other related projects). However, I would love any suggestions/feedback/collaborative requests.
by Jai Joshi
18th March, 2024