Skip to main content

NxNxN Rubik Cube implementation

Project description

MagicCube: 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)
print(cube)

Cube

# Rotate the cube
cube.rotate("R' L U D' F B' R' L")

# Solve the 3x3x3 cube
solver = BasicSolver(cube)
solver.solve()

# 6x6x6 Cube
cube = magiccube.Cube(6)
cube.rotate("Rw' Lw 3Uw'")

Examples

See examples folder.

Supported Moves and Notation

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.

Advanced Moves

Move
X X' Cube rotation on X axis. X is the axis that points from LEFT to the RIGHT face.
Y Y' Cube rotation on Y axis. Y is the axis that points from DOWN to the UP face.
Z Z' Cube rotation on Z axis. Z is the axis that points from BACK to the FRONT face.
M M' Rotation of the center layer on the X axis.
E E' Rotation of the center layer on the Y axis.
S S' Rotation of the center layer on the Z axis.
Fw Fw' Wide rotation of 2 layers.
3Fw 3Fw' Wide rotation of 3 layers.
3F 3F' Rotation of the 3rd layer.

Cube Coordinates

  • Cube coordinates are expressed as a tuple of x,y,z.
  • (0,0,0) is the piece on the LEFT,DOWN,BACK corner.
  • In a 3x3x3, (2,2,2) is the piece on the RIGH,UP,FRONT corner.

Solver

The solver uses the beginner method to solve the cube

Move Optimizer

The move optimizer does the following optimizations:

  • Eliminates redundant moves (ex: L L L L)
  • Converts 3x moves to the inverse (ex: F F F -> F')
  • Eliminates cube rotations (ex: Y F -> R)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

magiccube-0.0.5.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

magiccube-0.0.5-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file magiccube-0.0.5.tar.gz.

File metadata

  • Download URL: magiccube-0.0.5.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for magiccube-0.0.5.tar.gz
Algorithm Hash digest
SHA256 34c3ee802803c498a85150c1306a83823c2e8fffea1cc3295c1eab16a27d5e6c
MD5 0f1f5b8402340cbd3469ae7763aa570a
BLAKE2b-256 9a109cf3214e40c374b60716b410e79479ca0493ff1d4d1c434836349d9a2211

See more details on using hashes here.

File details

Details for the file magiccube-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: magiccube-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for magiccube-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 53820a2c10eed1e452bae3dc20c43c7682a2520bfef13089c38e05dbdb1f92c7
MD5 97c2c62961e92f4d940245b3ce2d45f7
BLAKE2b-256 6224a24b5afabf16331bdf975813aa9784de0b3c5b491c02ef5279a01dbaf8bd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page