A 3x3 rubik's cube solver made with Python.
The first two layers are solved using a home made algorithm. The last face is solved using the CFOP method.
It doesn't use any external libraries to solve the cube, all the logic is implemented using pure python.
> pip install pygame
> python gui.py
- Click on a selector at the bottom left of the screen.
- Click wherever you want to set the colour.
- Press the solve button
- The instructions will appear on the console according to the Singmaster notation but with "-" for the counter-clockwise rotations.
If there is a problem with the colours you have given, then an error will be indicated in the console.
The program has been tested to work with 1369 different scrambled cases.
In each case the cube was mixed with a random sequence of movements and the program successfully solved the cube.
These cases were provided by the tester in about 3 minutes. And are in the test_cases.txt file.
GUI | text-based UI | tester |
---|---|---|
A graphical user interface made with pygame. | A text-based interface created using pure python. | An infinite loop which tries to solve the cube previously scrambled with a random sequence, if the cube is solved then it tries another one. Useful to debug the program. |
gui.py | terminal_ui.py | tester.py |
The cube is represented with a two-dimensional list: cube_map. The list contains 6 lists, each representing a face of the cube. The colours are represented with numbers from 0 to 5.
A solved cube would look like this:
cube_map = [[4,4,4,4,4,4,4,4,4],[2,2,2,2,2,2,2,2,2],[5,5,5,5,5,5,5,5,5],[3,3,3,3,3,3,3,3,3],[1,1,1,1,1,1,1,1,1],[0,0,0,0,0,0,0,0,0]]
Home made algorithm for the first two layers and a simplified CFOP (Fridrich method) for the last layer.
-
white center down
a) red center in front / white-red edge in the bottom-front position
b) green center in front / white-green edge in the bottom-front position
c) orange center in front / white-orange edge in the bottom-front position
d) blue center in front / white-blue edge in the bottom-front position
for each color in (blue, red, green, orange)
-
blue center in front
a) white-red-blue corner in the top right position
b) correct corner correctly placed in the bottom right position
c) place correct edge
Solve the last cross according to 4 different cross' states.
Solves the cube according to 7 different cases. (OLL cross)
Solves the pll according to 21 pll cases.
Turns the last layer, the pll sometimes leaves one face to turn.
Python 3.10
gui.py | solver_utils | gui_utils | change_wd.py |
---|
terminal_ui.py | solver_utils | change_wd.py |
---|
______________________________
______ /_____________________________/
| _ \ _ _ _
| |_| | _ _ | | __ _ | | _ /_/ ______
| __/ | | | | | |/ \ | | | | / / / __ \
| |\ \ | | | | | /| | | | | |/ / | / |_|
| | \ \_ | |__| | | |_/ | | | | \ \ \
|_| \__| \______/ \_____/ |_| |_| \_\ \ \
\ \
________________________________________ _ \ \
/_______________________________________/ / / \ \
| |_ / |
\______/