PyCube Blog A 3D interactive Rubik's Cube
See the repo on GitHub

More on neural network coming in the future!

About the project


PyCube is an 3D interactive Rubik's Cube using OpenGL and Pygame. Quaternions are used to rotate the 3D plane and rotation matrices to rotate the pieces.

Purpose

This software-based Rubik's Cube will serve as a basis for a later project in which I will attempt to create another program, implementing a neural network algorithm, that will teach itself to solve a Rubik's Cube (PyCube).

Dependencies

This program utilizes the following Python modules:
PyOpenGL see also OpenGL
Pygame
NumPy

Python 3.x :
pip3 install pyopengl pygame numpy

Only supported by Python 3.x+. Try at your own risk.
Python 2.x :
pip install pyopengl pygame numpy

Notable Mentions

This post from stackoverflow was very helpful in creating a solid starting point to use quaternions to rotate a 3 dimensional cube using Python and OpenGL.

It's Looking Good ;)

by Michael

Posted


So the cube itself is nearing completion. I have implemented the corner pieces and applied the appropriate algorithm in order to make them rotate correctly, as well as colored them. I also adjusted the appearance a bit. I spaced out the pieces to give a more realistic look. I put a sphere in the center to symbolize the central spherical gear that's used in an actual Rubik's Cube (the newer versions). Lastly I experimented with an exploded view that separates the pieces and exposed the inside of the cube. From here I'm going to begin work on a 'reverse moves' solver.


PyCube Gif PyCube Gif

Things are moving fast

by Michael

Posted


I'm swiftly making significant progress. I have implemented all of the edge pieces and have also been able to make them rotate correctly with an algorithm that utilizes the rotation matrices. Correctly coloring each of the edge pieces and 'stickers' was an unforeseen challenge, but luckily I was able to tackle that one. Now I will continue on to implement the corner pieces which shouldn't be too hard considering they won't be much different from the edge pieces.


PyCube Gif

PyCube is under renovation.

by Michael

Posted


So over the summer I shelved PyCube until I started looking into graphics with OpenGL. Seeing how the graphics can be so much better compared to VPython I decided to revisit PyCube and rebuild it from the ground up using PyOpenGL, Pygame, NumPy, lots of quaternions, matrix math, and vector management. I think I'm off to a good start. I have a semi-working Rubik's cube with only the center pieces. You use the FBLRUD keys to rotate the faces. Lowercase for CW and [Shift] for CCW. Oh, and you can click and drag with the mouse to move the cube around (can also use arrow keys) as well as zoom in and out with the mouse wheel. I'm happy with the result but there is still a lot more work to be done.


PyCube Gif

PyCube VPython Rubik's Cube is alive!

by Michael

Posted


The first version of my Rubik's cube python program is finally alive. I still need to add a few more features and make a few tweaks but here it is!

Repo
PyCube Gif

About the project


PyCube is an 3D interactive Rubik's Cube using OpenGL and Pygame. Quaternions are used to rotate the 3D plane and rotation matrices to rotate the pieces.

Purpose

This software-based Rubik's Cube will serve as a basis for a later project in which I will attempt to create another program, implementing a neural network algorithm, that will teach itself to solve a Rubik's Cube (PyCube).

Dependencies

This program utilizes the following Python modules:
PyOpenGL see also OpenGL
Pygame
NumPy

Python 3.x :
pip3 install pyopengl pygame numpy

Python 2.x :
pip install pyopengl pygame numpy

Only supported by Python 3.x+. Try at your own risk.

Notable Mentions

This post from stackoverflow was very helpful in creating a solid starting point to use quaternions to rotate a 3 dimensional cube using Python and OpenGL.

Archives