How gavin-heaver/knighthacks_ix_syntax_error works
KnightHacks_IX_Syntax_Error is a Pygame tower-defense game in which players place defenses on a grid, defend a CPU from enemies, and program turrets with restricted Python scripts. The main loop coordinates the menu, board, combat entities, game state, and rendering; enemies follow weighted flow fields while tools run scripts and fire projectiles. The tree also includes wave, shop, HUD, and AI-planning modules, but their behavior was not sampled. Edges reflect visible calls, imports listed in the source index, or documented event behavior; unsampled subsystem links are omitted.
Main entry points: main.py Game Loop · tools.py Defense Tools · enemy.py Enemy Behavior · config.py Game Configuration
Components 25
Game Runtime
- Game Loop
main.py - Board Grid
game/board.py - Wave System
game/waves.py
Combat and AI
- Enemy Behavior
entities/enemy.py - Projectiles
entities/projectile.py - Defense Tools
entities/tools.py - Flow Fields
ai/flowField.py - Enemy Steering
ai/steering.py - AI Cost Layers
ai/costLayers.py - AI Director
ai/director.py - Pheromone AI
ai/pheromone.py
Tower Scripting
- Script Runner
scripting/runner.py - Script API
scripting/api.py - Default Scripts
scripting/defaults.py - Script Corruption
scripting/corruption.py
Player Interface
- Menu and Scores
ui/menu.py - Local Scoreboard
scoreboard.json - Code Editor
ui/editor.py - Debug Overlay
ui/debugOverlay.py - Game HUD
ui/hud.py - Defense Shop
ui/shop.py
Game State
- Event Bus
game/events.py - Game State
game/gameState.py - Game Configuration
config.py
Other components
- Player
Connections 25
- Player → Game Loop: plays
- Game Loop → Board Grid: creates and queries
main.py - Game Loop → Menu and Scores: handles and draws
main.py - Game Loop → Code Editor: handles editor
main.py - Game Loop → Game State: uses game state
main.py - Game Loop → Enemy Behavior: creates enemies
main.py - Game Loop → Defense Tools: updates tools
main.py - Game Loop → Flow Fields: builds field
main.py - Game Loop → Debug Overlay: draws arrows
main.py - Game Loop → Event Bus: imports event bus
main.py - Game Loop → Game Configuration: reads settings
main.py - Menu and Scores → Local Scoreboard: reads and writes
ui/menu.py - Enemy Behavior → Flow Fields: gets next step
entities/enemy.py - Enemy Behavior → Enemy Steering: uses separation
entities/enemy.py - Enemy Behavior → Event Bus: emits combat events
entities/enemy.py - Game State → Event Bus: subscribes to events
game/gameState.py - Defense Tools → Script Runner: runs turret scripts
entities/tools.py - Defense Tools → Default Scripts: loads default script
entities/tools.py - Defense Tools → Projectiles: creates projectiles
entities/tools.py - Script Runner → Script API: imports sandbox API
scripting/runner.py - Code Editor → Script Runner: compiles tool script
- Board Grid → Game Configuration: uses grid settings
game/board.py - Game State → Game Configuration: uses game rules
game/gameState.py - Defense Tools → Game Configuration: loads tool stats
entities/tools.py - Debug Overlay → Flow Fields: reads next steps
ui/debugOverlay.py