cube_solver.solver.kociemba module
Kociemba solver.
Implementation of the two-phase algorithm proposed by Herbert Kociemba.
For more information, see: https://kociemba.org/cube.htm
Examples
>>> from cube_solver import Cube, Kociemba
>>> solver = Kociemba()
>>> cube = Cube("L2 U R D' B2 D2 F B D")
>>> solver.solve(cube)
"D' F' B' U2 F2 D L' F2 D2 L2 F2 U D L2 B2 D L2"
Solution divided by phases.
>>> solver.solve(cube, verbose=2)
["D' F' B' U2 F2 D L", 'L2 F2 D2 L2 F2 U D L2 B2 D L2']
Find the optimal solution.
>>> solver.solve(cube, optimal=True)
"D' F' B' D2 B2 D R' U' L2"
- class cube_solver.solver.kociemba.Kociemba(use_transition_tables=True, use_pruning_tables=True)[source]
Bases:
BaseSolverCreate
BaseSolverobject.- Parameters:
use_transition_tables (bool, optional) – Whether to use transition tables for cube state transitions. If
True, creates or loads the tables from thetables/directory. Default isTrue.use_pruning_tables (bool, optional) – Whether to use pruning tables to reduce the tree search space. If
True, creates or loads the tables from thetables/directory. Default isTrue.
See also
solveSolve a cube position.
- num_phases: int = 2
Number of phases of the solving algorithm.
- partial_corner_perm: bool = False
Whether the solving algorithm uses the normal or the partial corner permutation.
- partial_edge_perm: bool = True
Whether the solving algorithm uses the normal or the partial edge permutation.
- static phase_coords(coords, phase)[source]
Get the coordinates for the specified phase.
- Parameters:
coords (tuple of int) – Flatten cube coordinates.
phase (int) – Solver phase (0-indexed).
- Returns:
phase_coords – Phase coordinates.
- Return type:
tuple of int
Notes
Depending on the class attributes
partial_corner_permandpartial_edge_perm, thecoordsparameter is the flattened version of the output from theget_coords()method.