src/crimson/) contains all game logic: gameplay modes, deterministic simulation, UI, persistence, and data tables.
Package Structure
Core Subsystems
CLI (Command-Line Interface)
Location:src/crimson/cli/
The CLI is the main entry point for the game:
src/crimson/cli/root.py
Game Flow
Location:src/crimson/game/
The game flow state machine manages screens and transitions:
- Splash screen
- Company logos
- Main menu
- Play Game panel
- Mode selection
- Gameplay
- Game over / Results
Simulation Core
Location:src/crimson/sim/
The deterministic simulation core:
world_state.py— Core world state and step logicstep_pipeline.py— Deterministic tick pipelinesessions.py— Mode-specific session adaptersinput_frame.py— Multiplayer input normalizationpresentation_step.py— Deterministic presentation planning
Game Modes
Location:src/crimson/modes/
All gameplay modes:
survival_mode.py— Endless wave survivalrush_mode.py— Timed scoring modequest_mode.py— Quest missions (5 tiers)tutorial_mode.py— Tutorial stagestypo_mode.py— Typ-o-Shooter typing gamereplay_playback_mode.py— Replay viewer
Creatures
Location:src/crimson/creatures/
ai.py— Creature AI (pathfinding, targeting)anim.py— Animation frame selectiondamage.py— Damage application and deathlifecycle.py— Spawn and despawn logicruntime.py— Creature pool managementspawn.py— Spawn templates and builders
Perks
Location:src/crimson/perks/
Perk system with three layers:
- Metadata —
ids.py,availability.py,selection.py - Implementation —
impl/*.py(one file per perk) - Runtime —
runtime/manifest.py,runtime/apply.py
Networking
Location:src/crimson/net/
- Rollback netcode (primary)
rollback.py— Core rollback logicrollback_runtime.py— Network integrationrelay_protocol.py— UDP relay protocolrelay_service.py— Relay server
- Lockstep netcode (fallback)
lan_protocol.py— LAN lockstep protocollan_lockstep.py— Lockstep host/client
Replay System
Location:src/crimson/replay/
codec.py— Replay encoding/decodingrecorder.py— Recording inputs during gameplaytypes.py— Replay file formatcheckpoints.py— State checkpoint system
Persistence
Location:src/crimson/persistence/
save_status.py—game.cfgsave filehighscores.py— High score tablesstats.py— Statistics tracking
Data Tables
Game content is defined in Python modules:Weapons
Location:src/crimson/weapons.py
Perks
Location:src/crimson/perks/ids.py
Bonuses
Location:src/crimson/bonuses/ids.py
Creatures
Location:src/crimson/creatures/spawn_templates.py
Key Contracts
GameWorld
Location:src/crimson/game_world.py
Main container for active game state:
WorldState
Location:src/crimson/sim/world_state.py
Deterministic simulation container:
Import Policy
Next Steps
Grim Module
Engine layer
Perks Module
Perk architecture
Replay Module
Replay system
Module Map
Full architecture