How slavik-mmmbech/seaborn works
1. Project shape
- Seaborn is a small Python game project, likely a procedural dungeon/exploration game based on the module names and tests.
- The architecture is split into clean subsystems: game/core runtime, procedural generation, entities, AI, spatial indexing, lighting, and loot.
2. Entry point and runtime boundary
- main.py is the top-level entry point.
- core/game.py appears to own the main game loop and runtime coordination.
- core/world.py likely holds the active world state: map, entities, generated content, and per-tick updates.
3. Core gameplay model
- The core package is the central boundary where “simulation state” lives.
- It likely orchestrates updates from AI, movement/collision, lighting refresh, and item interactions.
- config.py is the shared configuration layer for tuning game parameters such as sizes, counts, or gameplay constants.
4. Procedural generation subsystem
- The generation package is a dedicated dungeon-building pipeline.
- generation/bsp_tree.py suggests a BSP-based partitioning step.
- generation/room_generator.py and generation/corridor_generator.py indicate separate phases for creating rooms and connecting them.
- generation/dungeon.py probably composes those pieces into a complete map generation flow.
5. Spatial representation and queries
- spatial/quadtree.py provides a spatial indexing structure for fast neighborhood lookups.
- This is likely used for entity proximity, collision candidates, visibility checks, or lighting-related queries.
- The presence of a quadtree suggests the project separates broad-phase spatial queries from core world logic.
6. Entities and in-world actors
- entities/player.py, entities/npc.py, and entities/items.py define the game’s interactable objects.
- The entities layer is likely the domain model for actors and pickups, while core/world.py manages their placement and lifecycle.
- This boundary keeps object behavior close to the entity type while leaving world orchestration in core.
7. AI subsystem
- ai/behavior_tree.py and ai/markov_chain.py show two decision-making approaches in the project.
- Behavior trees are typically used for deterministic or rule-based NPC behavior.
- Markov chains likely provide probabilistic or pattern-based generation/behavior support.
- The AI layer probably consumes world state and emits actions for entities/npc.py.
8. Lighting and visibility
- lighting/lightmap_raycasting.py suggests a raycasting-based light or visibility system.
- This subsystem likely computes what tiles or entities are visible/illuminated from a source position.
- It probably depends on world geometry from generation and may use spatial acceleration for performance.
9. Loot and rewards
- loot/loot_bag.py and loot/weighted_binary.py form a loot-generation subsystem.
- weighted_binary.py likely implements weighted selection, used to control drop probabilities.
- loot_bag.py likely packages loot tables or drop logic and feeds spawned items into entities/items.py.
10. Cross-subsystem data flow
- A likely runtime flow is: main.py starts the game, core/game.py initializes core/world.py, the world is populated through generation/dungeon.py, then entities, AI, lighting, and loot systems operate on that generated state.
- The core world is the shared hub; generation creates the map, entities act within it, AI decides actions, lighting recomputes visibility, and spatial structures support efficient queries.
11. Testing strategy
- The tests package covers both unit-style and integration-level behavior.
- There are focused tests for generation components (test_bsp_tree, test_room_generator, test_corridor_generator), AI (test_markov_chain), spatial indexing (test_quadtree), and a broader test_dungeon_integration.
- This suggests the project values deterministic generation and composable subsystems.
12. Architectural boundaries to show in a diagram
- Treat core as the central orchestrator.
- Treat generation, ai, lighting, loot, and spatial as service-like subsystems feeding into or reading from the world.
- Treat entities as the runtime object layer that exists inside the world and is manipulated by the other systems.
Main entry points: world.py World · dungeon.py Dungeon · game.py Game · npc.py NPC
Components 17
Runtime
Application entry and game/world coordination
Generation
Procedural dungeon-building pipeline
Entities
In-world actors and pickups
AI
Decision systems for NPC behavior
- Behavior tree · Rule-based NPC decision logic
ai/behavior_tree.py - Markov chain · Probabilistic behavior or generation model
ai/markov_chain.py
World services
Supporting systems for queries, lighting, and loot
- Quadtree · Accelerates proximity and neighborhood queries
spatial/quadtree.py - Light raycasting · Computes lighting and visibility from rays
lighting/lightmap_raycasting.py - Loot bag · Packages loot tables and drops
loot/loot_bag.py - Weighted binary · Chooses outcomes by probability weights
loot/weighted_binary.py
Other components
- Config · Shared gameplay and generation constants
config.py
Connections 20
- main → Game: starts · Bootstraps the game runtime
- Game → World: owns · Creates and advances world state
- Game → Config: reads · Uses shared configuration
- World → Dungeon: generates · Builds the initial dungeon map
- Dungeon → BSP tree: partitions · Derives region structure
- Dungeon → Rooms: places · Creates room geometry
- Dungeon → Corridors: connects · Links generated rooms
- World → Player: contains · Tracks the player in the world
- World → NPC: contains · Tracks NPCs in the world
- World → Items: contains · Tracks loose items and pickups
- NPC → Behavior tree: uses · NPC behavior is driven by decisions
- NPC → Markov chain: uses · NPCs may use probabilistic behavior
- World → Quadtree: indexes · Supports fast spatial lookups
- World → Light raycasting: updates · Recomputes visibility from world geometry
- World → Loot bag: spawns · Generates reward drops
- Loot bag → Weighted binary: selects · Chooses weighted outcomes
- Loot bag → Items: creates · Produces item entities as loot
- Light raycasting → Quadtree: queries · May use spatial acceleration for ray or neighborhood checks
- Rooms → Config: reads · Uses generation tuning constants
- Corridors → Config: reads · Uses generation tuning constants