Skip to main content

core

This module provides the core class Solver, which loads a mode and finds Rubik's Cube solutions using a beam search algorithm.

Class:

  • Solver: A class for managing Rubik's Cube configuration, solving model, and search function.

Solver

class Solver()

A solver class for managing environment, model, and search configurations.

Methods:

  • load: Load the solver model and optimize it for CPU or GPU.
  • __call__: Set up the cube state and pass it for solution using beam search.

load

def load(model_id: str = "small" if device.type == "cpu" else "large", prefer_gpu: bool = True, quantize_on_cpu: bool = True, jit_mode: bool = False, *args, **kwargs)

Load the Rubik's Cube solver model and optimize it for CPU or GPU.

Arguments:

  • model_id str - Identifier for the model variant to load ("small", "base", or "large").
  • prefer_gpu bool - Whether to prefer GPU if available.
  • quantize_on_cpu bool - Whether to quantize the model for CPU optimization.
  • jit_mode bool - Whether to enable JIT mode for potentially faster execution.
  • *args - Additional arguments for model loading.
  • **kwargs - Additional keyword arguments for model loading and optimization.

Returns:

  • None

__call__

def __call__(scramble, format="moves", allow_wide=True, **kwargs)

Set up the cube state from format and scramble and pass it to search.beam_search together with **kwargs.

Arguments:

  • format str - Input format of the scramble: either "moves" or "stickers".
  • scramble list - A sequence of moves/stickers representing the initial state of the Rubik's Cube.
  • allow_wide bool - Whether wide moves are allowed.
  • **kwargs - Keyword arguments to be passed to beam_search.

Returns:

  • solutions dict | None - Dictionary containing the solution response from search.beam_search.