How desmitry/game works
1. Project shape
- This is a Python game project, likely a 2D stealth/survival game called Eclipsed Evolution.
- The repository is organized around a typical game architecture: game loop entrypoint, state management, entity models, AI systems, rendering, audio, and level/map loading.
2. Entry point and top-level control
- main.py is the application entrypoint.
- The controllers/game_controller.py module appears to own the high-level runtime orchestration: starting the game, switching states, and coordinating updates between subsystems.
3. Game state management
- src/states/ contains the state machine layer.
- main_menu_state.py and game_state.py indicate at least two major runtime modes: menu and active gameplay.
- This boundary separates UI/menu logic from in-game simulation, which is important for the architecture diagram.
4. World and level loading
- src/systems/level.py and src/systems/map_loader.py handle construction of the playable world from map data.
- src/maps/test_level.txt is the current example level asset, suggesting levels are data-driven from text map files.
- src/models/wall.py, trapdoor.py, pickup.py, and related classes are the concrete world objects instantiated from these level definitions.
5. Entity/model layer
- src/models/ contains the game’s core entities and interactables: player, enemy, flashlight, flare, health, pickup, trapdoor, and wall.
- These are likely lightweight game objects used by the simulation and renderer rather than isolated business objects.
- The model layer is the shared contract consumed by AI, physics/visibility, rendering, and game state logic.
6. AI subsystem
- src/ai/ is a substantial AI layer with multiple strategies:
- astar.py and pathfinding_grid.py handle navigation/path search.
- bt_node.py, bt_composites.py, bt_actions.py, and bt_chase.py implement behavior trees.
- This suggests enemies are driven by a combination of pathfinding and behavior-tree decision making rather than a single monolithic AI loop.
7. Enemy decision and movement flow
- src/models/enemy.py is the entity that likely binds together sensing, behavior selection, and movement execution.
- AI decisions likely depend on visibility and navigation systems, then translate into world movement across the level grid.
- src/systems/vision_cone.py and raycast.py suggest enemy perception is line-of-sight based.
8. Perception, lighting, and visibility
- src/rendering/lightmap.py, src/systems/vision_cone.py, and src/systems/raycast.py point to a visibility-centric game loop.
- models/flashlight.py and models/flare.py imply the player can influence visibility, which likely affects both gameplay and rendering.
- This is a major architectural boundary: world state influences visibility, and visibility influences both rendering and AI detection.
9. Rendering pipeline
- src/rendering/renderer.py is the main draw pipeline.
- lightmap.py likely supplements rendering with darkness/shadow or illumination effects, which is consistent with the game’s title and stealth mechanics.
- src/systems/text_renderer.py supports HUD or menu text output, probably used by both game state and main menu state.
10. Core simulation helpers
- src/systems/uniform_grid.py suggests spatial partitioning for efficient collision, querying, or neighbor lookup.
- src/systems/object_pool.py indicates reuse of transient objects, likely for performance-sensitive items like projectiles, flares, or temporary effects.
- src/systems/genome.py and genetic_algorithm.py indicate an evolutionary simulation component, possibly for tuning enemy behavior or procedural traits.
11. Audio
- src/audio/sound_manager.py is the centralized audio boundary.
- It likely mediates all sound playback so gameplay code does not talk directly to the underlying audio backend.
12. Testing and validation
- tests/test_astar.py, tests/test_uniform_grid.py, and tests/test_genetic_algorithm.py show the repo has unit coverage for the most algorithmic subsystems.
- That means the architecture includes both game-specific runtime code and isolated algorithmic components that can be validated independently.
13. Likely dependency direction
- Higher-level flow is: entrypoint/controller → state machine → level load → entities/models + systems → rendering/audio.
- AI and visibility systems read from the same model/level data, while rendering consumes the resulting world state each frame.
- Tests target the standalone algorithms beneath the gameplay layer, especially pathfinding, spatial indexing, and evolutionary logic.
Main entry points: game_state.py Game State · level.py Level · game_controller.py Game Ctrl · enemy.py Enemy
Components 21
Runtime
Application entry, control, and game states
- Main · Starts the application and launches the controller
main.py - Game Ctrl · Owns runtime flow and state switching
src/controllers/game_controller.py - Menu State · Main menu runtime mode
src/states/main_menu_state.py - Game State · Active gameplay and simulation mode
src/states/game_state.py
World Model
Levels, entities, and map assets
- Level · Builds playable world from map data
src/systems/level.py - Map Loader · Reads text map definitions
src/systems/map_loader.py - Test Map · Example text-based level
src/maps/test_level.txt - Player · Controllable character model
src/models/player.py - Enemy · Hostile model with AI hooks
src/models/enemy.py - World Obj · Walls, pickups, traps, health, flashlight, flare
src/models/wall.py
AI
Navigation and behavior logic
- A* · Grid path search for navigation
src/ai/astar.py - Behavior Tree · Composable enemy behavior logic
src/ai/bt_node.py - Path Grid · Navigation grid used by pathfinding
src/ai/pathfinding_grid.py
Rendering
Draw pipeline and visibility effects
Systems
Reusable simulation helpers
- Vision · Line-of-sight and cone checks
src/systems/vision_cone.py - Raycast · Ray-based obstruction and sight queries
src/systems/raycast.py - Text Draw · Renders menu and HUD text
src/systems/text_renderer.py - Genetic Alg · Evolutionary simulation and tuning logic
src/systems/genetic_algorithm.py - Genome · Data model for evolutionary traits
src/systems/genome.py
Platform
Cross-cutting services
- Sound · Centralized audio playback boundary
src/audio/sound_manager.py
Connections 20
- Main → Game Ctrl: launches · Application startup hands off to the controller
- Game Ctrl → Menu State: shows · Controller can activate the menu state
- Game Ctrl → Game State: runs · Controller can activate the gameplay state
- Game State → Level: loads · Gameplay initializes world content through level construction
- Level → Map Loader: parses · Level construction depends on map parsing
- Map Loader → Test Map: reads · Loader consumes text map assets
- Level → Player: spawns · Player entity is part of the world
- Level → Enemy: spawns · Enemy entities are part of the world
- Level → World Obj: instantiates · Walls, pickups, traps, and gear are created from level data
- Enemy → Behavior Tree: decides · Enemy behavior is driven by behavior trees
- Enemy → A*: navigates · Enemy movement can use path search
- A* → Path Grid: queries · A* operates on a navigation grid
- Enemy → Vision: senses · Enemy perception uses visibility checks
- Vision → Raycast: uses · Vision is implemented with ray-based obstruction queries
- Game State → Renderer: draws · Gameplay frame updates are rendered each tick
- Renderer → Lightmap: applies · Lighting affects final frame output
- Game State → Text Draw: hud · Gameplay and menu text use the text renderer
- Game Ctrl → Sound: plays · Audio is coordinated as a shared runtime service
- Game State → Genetic Alg: tunes · Evolutionary logic supports gameplay simulation or balancing
- Genetic Alg → Genome: models · Evolution operates on genome data