Library that implements a representation of a Rubik's Cube. The purpose of this implementation is to use it for research purposes.
The easiest way to create a Rubik's Cube is with
the RubikCube
class. Here is an example:
from rubiks_cube.cube import RubikCube
rc = RubikCube.from_dims((3, 2, 1))
print(rc)
Noting that a RubikCube
instance is a hashable and immutable object (with the current methods).
If you want to make a move on the Rubik's Cube, you can do it like the example:
from rubiks_cube.cube import RubikCube
from rubiks_cube.movements import CubeMove
rc = RubikCube.from_dims((3, 2, 1))
rc = rc.make_movements(CubeMove.L2)
print(rc)
You can make a series of movements with a list of CubeMove
:
from rubiks_cube.cube import RubikCube
from rubiks_cube.movements import CubeMove
rc = RubikCube.from_dims((3, 2, 1))
rc = rc.make_movements([CubeMove.L2, CubeMove.U2])
print(rc)
Or with a string with the representation of CubeMove
:
from rubiks_cube.cube import RubikCube
rc = RubikCube.from_dims((3, 2, 1))
rc = rc.make_movements("L2 U2")
print(rc)
Given a set of permitted movements (where the permitted movements are operations over the group of Rubik's Cube), for example, . We expect to create a graph where and The described graph can be computed with the following instructions:
from matplotlib import pyplot as plt
from rubiks_cube.graph import make_graph
from rubiks_cube.movements import CubeMove as CM
from rubiks_cube.plotters import GraphPlotter
g = make_graph(
dims=(3, 2, 1),
permitted_movements={CM.R2, CM.D2, CM.U2}
)
gp = GraphPlotter(g)
gp.compute_kamada_kawai_layout()
gp.find_bipartite()
gp.draw()
plt.show()