Skip to content

Latest commit

Β 

History

History
73 lines (59 loc) Β· 2.64 KB

File metadata and controls

73 lines (59 loc) Β· 2.64 KB

Architecture

Module Dependency Graph

main.py (CLI entry point)
  β”œβ”€β”€ config.py (configuration loading)
  β”œβ”€β”€ manual_mode.py
  β”‚     β”œβ”€β”€ cube_engine.py (cube state)
  β”‚     β”œβ”€β”€ moves.py (move execution)
  β”‚     β”œβ”€β”€ parser.py (notation parsing)
  β”‚     β”œβ”€β”€ renderer.py (3D rendering)
  β”‚     β”œβ”€β”€ input_handler.py (keyboard input)
  β”‚     β”œβ”€β”€ solver.py (kociemba integration)
  β”‚     └── utils.py (terminal utilities)
  └── auto_mode.py
        β”œβ”€β”€ cube_engine.py
        β”œβ”€β”€ moves.py
        β”œβ”€β”€ renderer.py
        └── utils.py

Module Descriptions

cube_engine.py

Core cube state: dictionary mapping face names to 9-element sticker arrays. Provides solved-state factory, is_solved(), state copy/load, move history tracking (undo/redo stacks), and scramble generation.

moves.py

All 18 face moves (R/L/U/D/F/B Γ— CW/CCW/double) and 6 cube rotations (x/y/z Γ— both directions). Each move mutates sticker arrays in-place via direct index permutations. Includes dispatch table, inverse lookup, and undo()/redo() functions.

parser.py

Parses space-separated cube notation strings into validated token lists. Handles Unicode prime characters and provides clear error messages.

renderer.py

Two rendering modes:

  • 3D Isometric: Shows top, front, and right faces with brightness-based depth shading using ANSI truecolour backgrounds.

Also renders: animated pyfiglet banner, live status bar, full frame composer.

config.py

TOML configuration with layered priority (CLI > local file > global file > defaults). Uses tomllib (3.11+) with tomli fallback. Provides the rubui init config file generator.

input_handler.py

Cross-platform raw keyboard input (msvcrt on Windows, termios on Unix). Key-to-move mapping, 350ms double-turn detection, integrated command prompt mode, and special key handling.

manual_mode.py

Main interactive game loop: render β†’ read input β†’ animate move β†’ repeat. Includes animated startup banner, live status bar, help overlay, command prompt, and clean terminal lifecycle management.

solver.py

Converts the current cube state into Kociemba facelet order (URFDLB) and invokes the kociemba package to return a move sequence that solves the cube.

auto_mode.py

Screensaver mode: picks random moves at configurable speed, renders continuously, responds to quit/mode-switch.

utils.py

Terminal primitives: ANSI support detection (with Windows VT processing enablement), cursor/screen control, RGB colour helpers, theme definitions (dark/light/monochrome), frame timer, and time formatting.