- Saved searches
- Use saved searches to filter your results more quickly
- License
- tdrmk/rubik_cube
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- Saved searches
- Use saved searches to filter your results more quickly
- License
- MeepMoop/py222
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
- Saved searches
- Use saved searches to filter your results more quickly
- License
- adrianliaw/PyCuber
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Implementing a Rubik’s Cube in pygame.
License
tdrmk/rubik_cube
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
- Modelling Rubik’s cube in python.
- Rendering the cube in 3D.
- Rotating the cube in 3D based on user input from keyboard and mouse.
- Visualising the rotations and moves of the cube.
- Animating transitions accompanying rotations.
- Automate solving rubik’s cube by computer using known algorithms.
L is for rotating LEFT face. R is for rotating RIGHT face. U is for rotating UP face. D is for rotating DOWN face. F is for rotating FRONT face. B is for rotating BACK face.
X is for rotating about RIGHT axis. Y is for rotating about UP axis. Z is for rotating about FRONT axis.
SHIFT is for anti-clockwise rotation, by default clockwise rotation. CTRL is for moving two layers together.
mouse drag is for rotating the cube. ←, ↑, →, ↓, [, ] for rotating the cube using keys.
S is for saving current cube spatial orientation. I is for resetting the cube spatial orientation to previously saved orientation.
H is for randomly shuffling using 50 steps. J is for solving till the next step. K is for solving the entire cube. Pressing SHIFT along with the above keys visualizes the moves.
ESC and Q for quiting the simulation.
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Python 2×2 Rubik’s Cube representation & solver
License
MeepMoop/py222
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Py222 is a 2x2x2 Rubik’s Cube representation written in Python. It has support for applying individual moves to the puzzle, as well as space-separated algorithm strings specified in WCA notation.
A cube’s state is represented as a 24-element numpy array with indices corresponding to the following stickers, and values corresponding to the following face colors:
sticker indices: ┌──┬──┐ │ 0│ 1│ ├──┼──┤ │ 2│ 3│ ┌──┬──┼──┼──┼──┬──┬──┬──┐ │16│17│ 8│ 9│ 4│ 5│20│21│ ├──┼──┼──┼──┼──┼──┼──┼──┤ │18│19│10│11│ 6│ 7│22│23│ └──┴──┼──┼──┼──┴──┴──┴──┘ │12│13│ ├──┼──┤ │14│15│ └──┴──┘ face colors: ┌──┐ │ 0│ ┌──┼──┼──┬──┐ │ 4│ 2│ 1│ 5│ └──┼──┼──┴──┘ │ 3│ └──┘
The move definitions are written for a sticker representation, but there are functions to normalize the state’s stickers relative to a fixed DLB corner, and convert it into a fixed-corner piece orientation and permutation (OP) representation. There are also various functions that can hash the fixed-corner OP representation state into unique integer indices.
Also included is a sample IDA* solver (solver.py).
import py222 # get solved state s = py222.initState() py222.printCube(s)
┌──┬──┐ │ 0│ 0│ ├──┼──┤ │ 0│ 0│ ┌──┬──┼──┼──┼──┬──┬──┬──┐ │ 4│ 4│ 2│ 2│ 1│ 1│ 5│ 5│ ├──┼──┼──┼──┼──┼──┼──┼──┤ │ 4│ 4│ 2│ 2│ 1│ 1│ 5│ 5│ └──┴──┼──┼──┼──┴──┴──┴──┘ │ 3│ 3│ ├──┼──┤ │ 3│ 3│ └──┴──┘
# do some moves s = py222.doAlgStr(s, "x y R U' R' U' F2 U' R U R' U F2") py222.printCube(s)
┌──┬──┐ │ 2│ 2│ ├──┼──┤ │ 2│ 2│ ┌──┬──┼──┼──┼──┬──┬──┬──┐ │ 0│ 3│ 1│ 4│ 3│ 0│ 4│ 1│ ├──┼──┼──┼──┼──┼──┼──┼──┤ │ 3│ 3│ 1│ 1│ 0│ 0│ 4│ 4│ └──┴──┼──┼──┼──┴──┴──┴──┘ │ 5│ 5│ ├──┼──┤ │ 5│ 5│ └──┴──┘
# normalize stickers relative to DLB s = py222.normFC(s) py222.printCube(s)
┌──┬──┐ │ 0│ 0│ ├──┼──┤ │ 0│ 0│ ┌──┬──┼──┼──┼──┬──┬──┬──┐ │ 1│ 4│ 2│ 5│ 4│ 1│ 5│ 2│ ├──┼──┼──┼──┼──┼──┼──┼──┤ │ 4│ 4│ 2│ 2│ 1│ 1│ 5│ 5│ └──┴──┼──┼──┼──┴──┴──┴──┘ │ 3│ 3│ ├──┼──┤ │ 3│ 3│ └──┴──┘
import py222 import solver # get solved state s = py222.initState() # apply some scramble s = py222.doAlgStr(s, "R U2 R2 F2 R' F2 R F R") # solve cube solver.solveCube(s)
┌──┬──┐ │ 2│ 3│ ├──┼──┤ │ 1│ 0│ ┌──┬──┼──┼──┼──┬──┬──┬──┐ │ 1│ 3│ 5│ 4│ 2│ 2│ 4│ 3│ ├──┼──┼──┼──┼──┼──┼──┼──┤ │ 4│ 2│ 0│ 0│ 4│ 1│ 0│ 5│ └──┴──┼──┼──┼──┴──┴──┴──┘ │ 1│ 5│ ├──┼──┤ │ 3│ 5│ └──┴──┘ normalizing stickers. generating pruning tables. searching. depth 1 depth 2 depth 3 depth 4 depth 5 depth 6 depth 7 depth 8 F R2 F' R U2 R2 F' R F R2 F' R' F R2 U2 R'
About
Python 2×2 Rubik’s Cube representation & solver
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Rubik’s Cube solver in Python
License
adrianliaw/PyCuber
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
PyCuber is a Rubik’s Cube package in Python 2/3
The cube can be revealed as expanded view in the terminal, so it’s easy to visualise the cube, just inside the terminal. (Not tested on Windows)
import pycuber as pc # Create a Cube object mycube = pc.Cube() # Do something at the cube. mycube("R U R' U'") print(mycube)
We also provided some useful tools to deal with Rubik’s Cube formulae.
import pycuber as pc # Create a Formula object my_formula = pc.Formula("R U R' U' R' F R2 U' R' U' R U R' F'") # Reversing a Formula my_formula.reverse() print(my_formula) # Mirroring a Formula object my_formula.mirror("LR") print(my_formula)
F R U' R' U R U R2 F' R U R U' R' F' L' U L U' L' U' L2 F L' U' L' U L
I’ll add some documentations later.