File | Date | Author | Commit |
---|---|---|---|
.github | 2025-02-09 |
![]() |
[601552] Missed an s |
docs | 2025-02-08 |
![]() |
[189f38] First Screenshot |
test | 2025-02-07 |
![]() |
[40dbb7] Latest |
twophase | 2025-02-08 |
![]() |
[8fefee] Added secondary license |
LICENSE.md | 2025-02-06 |
![]() |
[5f4ffa] Latest |
README.md | 2025-02-09 |
![]() |
[a26994] Some updated text |
app_icon.py | 2025-02-08 |
![]() |
[660b49] Latest |
colors.py | 2025-02-05 |
![]() |
[e7daa0] Separated Files |
cube_model.py | 2025-02-07 |
![]() |
[b27d60] Latest |
cubecolor.py | 2025-02-05 |
![]() |
[e7daa0] Separated Files |
gl_widget.py | 2025-02-08 |
![]() |
[48ce0e] Latest |
icon.ico | 2025-02-08 |
![]() |
[0908d9] Windows ICON |
icon.jpg | 2025-02-08 |
![]() |
[42b4f3] Latest |
main.py | 2025-02-07 |
![]() |
[2e8320] Latest |
main_window.py | 2025-02-09 |
![]() |
[a26994] Some updated text |
requirements.txt | 2025-02-06 |
![]() |
[cc3505] Latest |
rubiksolver.py | 2025-02-09 |
![]() |
[f37d1e] Latest |
A Python-based interactive Rubik's Cube simulator and solver built with PyQt5 and OpenGL. This application provides a 3D visualization of a Rubik's cube that users can manipulate, color, and solve.
This project was created as a demonstration of 3D graphics programming with Python and OpenGL, combining interactive graphics with a classic puzzle game.
git clone https://github.com/jasonbrianhall/rubikscube.git
cd rubikscube
pip install -r requirements.txt
Run the application using:
python main.py
When launched, the application opens a window displaying a 3D Rubik's cube with the following interface elements:
Arrow Up/Down: Rotate entire cube vertically
Row Rotations:
F: Rotate bottom row clockwise
Column Rotations:
G: Rotate back column down
Face Rotations:
main.py
: Application entry pointmain_window.py
: Main window UI implementationgl_widget.py
: OpenGL widget for 3D renderingcube_model.py
: Rubik's cube model and logiccolors.py
: Color definitions and enumsrubiksolver.py
: Function to bridge the json representing the cube to a Kociemba string text representation.twophase
: Directory containing the logic to actually solve the cubeapp_icon.py
: Base64 encoded Icon used to make the game prettier in MS Windows instead of the generic iconThe software converts a dictionary created by the OpenGL software into a python dictionary and that in turn gets converted to kociemba string which then is ran through a search pattern to solve the puzzle. When the program first runs, it will create a .rubikscube/tables.json in the users home directory (this creation usually takes about a minute) which then speeds up any future solve time. Without this feature, solve times would average a minute or more each time. If tables.json gets corrupted, it will have to be manually deleted and recreated.
The cube is modeled as 27 individual cubelets (3x3x3), each with up to six faces. The state of each cubelet is tracked using:
- Position coordinates (x, y, z)
- Face colors
- Face visibility (exterior vs interior)
The application supports three types of rotations:
1. Row rotations (horizontal layers)
2. Column rotations (vertical layers)
3. Face rotations (front/back faces)
Each rotation is animated smoothly using a timer-based animation system.
Colors are implemented using an Enum class that defines:
- Standard cube colors (Red, Yellow, Green, Blue, Orange, White)
- Special states (Unassigned, Interior)
The cube is rendered using OpenGL with:
- Perspective projection
- Depth testing
- Face culling
- Smooth animations
- Click detection for face coloring
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License
Copyright (c) 2025 Jason Hall (jasonbrianhall@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.