Skip to content

LindomarRodrigues/MagicCube

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MagicCube

Python 3 implementation of a (3x3x3) Rubik's Cube utility.

3x3x3 Rubik's Cube

TODO (Open to contributions)

  • CFOP is not Optimal, need to reimplement F2L and refactor PLL
  • Refactor Cube class to be more easy to understand
  • Replace VisualCube with a custom implementation of a 3D cube visualization
  • Add more solvers
  • Add support for other cube sizes (2x2x2, 4x4x4, 5x5x5, etc.)
  • Add support for other cube types (Pyraminx, Megaminx, etc.)

Installation

Clone the repository and navigate to the project directory:

git clone https://github.com/LindomarRodrigues/MagicCube.git
cd rubiks-cube

Install the required packages:

pip install -r requirements.txt

Usage

To use the utility, import the Cube class from the cube module:

from cube import Cube

Create a new instance of the Cube class:

cube = Cube()

Print or plot the cube:

cube.pprint()

# or

cube.plot()

Perform a sequence of moves:

cube.move("R U R' U'")

Solver the cube using Layer by Layer (LBL) method:

from solvers.layer_by_layer import LayerByLayerSolver

solver = LayerByLayerSolver(cube)
solver.solve()

print(solver.moves)

Or using the Fridrich(CFOP) method:

from solvers.CFOP import CfopSolver

solver = CfopSolver(cube)
solver.solve()

print(solver.moves)

Optimize the sequence of moves:

from solvers.optimizer import optimize_moves

print(len(moves))
moves = optimize_moves(moves)
print(len(moves))

Misc

To use a custom VisualCube server, set the VISUAL_CUBE_HOST environment variable:

export VISUAL_CUBE_HOST="http://localhost:80"

Releases

No releases published

Packages

No packages published

Languages