Expand description
Native runner. Two threads:
- main thread: owns the terminal, renders snapshots of the game state,
captures crossterm events, normalizes them into
crate::input::InputEvents, and feeds them to the platform-agnostic input router (which producesActions + mutatesUiState). Never blocks the sim — a slow render (SSH lag, terminal resize, stuck flush) is invisible to game logic. - sim thread: owns the canonical
GameState, runs the 20Hz tick loop viacrate::sim::sim_tick, drainsActions, saves to disk through thePersistenceimpl, and publishes snapshots viaArcSwap. Tick cadence is driven bympsc::recv_timeout(until_next_tick), so it wakes exactly on tick deadlines or incoming actions — no busy spin, no lost ticks under arbitrary render delay.
The cross-platform half (input router, apply_action, sim_tick) is in
src/input.rs and src/sim.rs. This file owns native-specific glue:
crossterm event translation, threading, save scheduling, and the
demo-recorder autopilot.
Structs§
Functions§
- build_
demo_ state - Rich starting state for
--demo-for-recording. Tuned so a viewer sees numbers moving fast (high FPS → counter spins visibly) and many rings of hands around the biscuit (heavy owned counts). Starting cuques is intentionally modest relative to FPS so the HUD counter grows by a visible fraction every frame instead of looking frozen.