API Reference#
Read, cache, and decode One Up puzzles for the solver and GUI.
The public API ships a compact string with size, clues, and wall data; this module fetches it (with a tiny JSON cache) and returns typed arrays ready for rendering or solving. See also {py:mod}`oneup_solver.gui.
- class oneup_solver.puzzle.Cell(row: int, col: int, clue: bool = False, value: int | None = None)#
Bases:
objectSingle board cell with coordinates, given clue, and current value.
- row: int#
- col: int#
- clue: bool#
- value: int | None#
- class oneup_solver.puzzle.Puzzle(size: int, clues: ndarray[tuple[Any, ...], dtype[int64]], walls_right: ndarray[tuple[Any, ...], dtype[int64]], walls_down: ndarray[tuple[Any, ...], dtype[int64]])#
Bases:
objectDecoded One Up puzzle data ready for display or solving.
- size: int#
- clues: ndarray[tuple[Any, ...], dtype[int64]]#
- walls_right: ndarray[tuple[Any, ...], dtype[int64]]#
- walls_down: ndarray[tuple[Any, ...], dtype[int64]]#
- property fixed_mask: ndarray[tuple[Any, ...], dtype[bool]]#
Boolean mask of given clues (non-zero cells).
- classmethod load(sid: str, *, session: Session | None = None, cache_path: Path | None = None, use_cache: bool = True) Puzzle#
Fetch and decode a puzzle id into a ready-to-use model.
Falls back to the local cache before hitting the public endpoint. Internal helpers _fetch and _decode keep the steps explicit.
- validate(board: ndarray[tuple[Any, ...], dtype[int64]]) set[tuple[int, int]]#
Return coordinates that violate segment rules against the given board.
- class oneup_solver.puzzle.Segment(cells: list[Cell])#
Bases:
objectContiguous run of cells without walls in one direction.
- validate() set[tuple[int, int]]#
Return offending cells when the segment has duplicates or out-of-range values.
- oneup_solver.puzzle.to_ascii(puzzle: Puzzle, values: ndarray[tuple[Any, ...], dtype[int64]] | None = None) str#
Render a plain ASCII board with walls and numbers.
- class oneup_solver.gui.OneUpGame(puzzle: Puzzle)#
Bases:
object- create_ui() None#
Crea la interfaz del puzzle.
- oneup_solver.gui.main(pid: str, *, host: str = '127.0.0.1', port: int = 8080, log_level: str = 'warning') None#