NxNxN Rubik Cube implementation
Low maintenance activity. Last release 19 months ago, commits in 0 of the last 26 weeks. Weaker on commit activity and recent releases.
$
pip install magiccubeMagicCube: A NxNxN Rubik Cube implementation
A fast implementation of the Rubik Cube based in Python 3.x.
Makes it easy to create cubes of various sizes (2x2x2, 3x3x3, 4x4x4, 6x6x6, ...., 100x100x100).
Fast rotation speed when compared with other Python implementations, which makes it suitable for Rubik Cube simulations.
Includes:
- Simple solver for the 3x3x3 cube.
- Move optimizer which reduces the number of moves.
Installation
pip install magiccube
Usage
import magiccube
# 3x3x3 Cube
cube = magiccube.Cube(3,"YYYYYYYYYRRRRRRRRRGGGGGGGGGOOOOOOOOOBBBBBBBBBWWWWWWWWW")
print(cube)

# Rotate the cube
cube.rotate("R' L2 U D' F B'2 R' L")
# Solve the 3x3x3 cube
from magiccube import BasicSolver
solver = BasicSolver(cube)
solver.solve()
# Complex moves 6x6x6 Cube
cube = magiccube.Cube(6)
cube.rotate("Lw") # L wide rotation
cube.rotate("Lw'") # L wide counter-rotation
cube.rotate("Lw2") # 2x L wide rotation
cube.rotate("3L") # 3rd line L rotation
cube.rotate("3Lw") # 3rd line L wide rotation
cube.rotate("3Lw'2") # 2x 3rd line L wide counter-rotation
# Get cube state
print("State:", cube.get())
# Get cube state in Kociemba order
print("State (Kociemba):", cube.get_kociemba_facelet_colors())
Documentation and Examples
Supported Moves and Notation
Uses SIGN notation, including advanced extensions.
Basic moves
| Move | |
|---|---|
| L L' | Clockwise/Counterclockwise cube rotation of the LEFT face. |
| R R' | Clockwise/Counterclockwise cube rotation of the RIGHT face. |
| D D' | Clockwise/Counterclockwise cube rotation of the DOWN face. |
| U U' | Clockwise/Counterclockwise cube rotation of the UP face. |
| F F' | Clockwise/Counterclockwise cube rotation of the FRONT face. |
| B B' | Clockwise/Counterclockwise cube rotation of the BACK face. |