cube_solver.solver.korf module

Korf solver.

Implementation of a simple one-phase algorithm that uses pruning tables proposed by Richard E. Korf.

For more information, see: https://en.wikipedia.org/wiki/Optimal_solutions_for_the_Rubik%27s_Cube#Korf’s_algorithm

Examples

>>> from cube_solver import Cube, Korf
>>> solver = Korf()
>>> cube = Cube("L2 U R D' B2 D2 F B")
>>> solver.solve(cube)
"F' B' D2 B2 D R' U' L2"
class cube_solver.solver.korf.Korf(use_transition_tables=True, use_pruning_tables=True)[source]

Bases: BaseSolver

Create BaseSolver object.

Parameters:
  • use_transition_tables (bool, optional) – Whether to use transition tables for cube state transitions. If True, creates or loads the tables from the tables/ directory. Default is True.

  • use_pruning_tables (bool, optional) – Whether to use pruning tables to reduce the tree search space. If True, creates or loads the tables from the tables/ directory. Default is True.

See also

solve

Solve a cube position.

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_perm and partial_edge_perm, the coords parameter is the flattened version of the output from the get_coords() method.