Puzzle Cube

A Python program that simulates the functionality of a standard 3x3 puzzle cube. The program will eventually work to find optimal solutions to any puzzle cube scramble. As of right now, it can randomly mix a cube.

Inspiration & Foundation

Solving puzzle cubes has been my hobby for the longest time, so I thought I would take that experience and merge it with my love for programming. I wanted to start this project completely clean without any walkthroughs or tutorials: just my pure knowledge and any research about the functionality and statistics of the cube that I could find. I also wanted a project that was more back-end heavy. I want to push my abilities of Data Structures and object-oriented design in Python: a language I have become quite fond of.

The Basics

Puzzle cubes are extremely complicated, and it will take an extremely long time to explain the complexities of it for this project, so I will explain things simply, not everything will make sense, but bear with me. Because this project is purely back-end, anyone without programming knowledge will be completely lost. Take a look at the flattened image of the cube. This is the best way to represent a 3-D cube in 2-D. The program corresponds colors with integers to make the writing process faster. 0 is white, 1 is orange, 2 is green, 3 is red, 4 is blue, and 5 is green. The cube can be moved by turning one of the 6 faces clockwise, counterclockwise or a 180 degree turn (direction does not matter). Those moves are represented by the letters on the image. A single clockwise turn of the green face is considered F. A counterclockwise turn of the green face is considered F', which is pronounced "F prime." A 180 degree turn in either direction of the green face is F2. This terminology works for any of the faces with their corresponding letters and is the standard way to define moves for all competitive cube solvers.

Stage 1

I am building this program in stages, since I am not sure when/if I will ever make the end result. Stage one is to make a functioning cube that can be scrambled. With the terminology explained before in mind, you can see the output of the program below illustrate the image of the cube via the __str__ method. Below that I printed out twenty random moves of the cube to scramble it using the Scramble Class. If a person were to take a standard 3x3 solved puzzle cube and move the corresponding moves (assuming they hold it in the correct orientation with white on top and green facing the person), the physical cube will look exactly the same as the cube in the program.

Having issues? Try refreshing the page.