3.2 KiB
3.2 KiB
Task 12: Dungeon Recipe + Integration Tests
Depends on: Task 7, Task 8, Task 9, Task 10, Task 11
Context Files
.dev/2026-05-28-procgen-map-core/spec/design.md— §4.8 (recipes), §8 (error handling), §9 (testing), §10 (acceptance)..dev/2026-05-28-procgen-map-core/README.md— inter-pass data contract (the full chain).reikhelm-core/src/pass.rs—Pipeline(Task 6).reikhelm-core/src/passes/mod.rs— all five passes + their configs (Tasks 7–11).reikhelm-core/src/lib.rs— append the module declaration here.
Files
- Create:
reikhelm-core/src/recipes/mod.rs— recipes module root; appendpub mod dungeon;. - Create:
reikhelm-core/src/recipes/dungeon.rs—DungeonConfig,ConfigError,dungeon(); integration tests. - Modify:
reikhelm-core/src/lib.rs— appendpub mod recipes;.
What to Build
The dungeon recipe (spec §4.8): a function that validates a config and assembles the full pipeline — BspPartition → RoomCarver → MstConnect → CorridorCarver → DoorPlacer — sized to the config. DungeonConfig composes the per-pass configs and the map dimensions, with sensible Defaults. Validation (spec §8) runs at recipe construction: dimensions > 0, and the room min size must be able to fit within the smallest possible BSP leaf (min_leaf), returning ConfigError rather than panicking. This task also carries the cross-pass integration tests (spec §9) that prove the whole chain works.
Interface Dependencies
- Consumes:
Pipeline(Task 6); all five passes + configs (Tasks 7–11). - Produces:
struct DungeonConfig { width: u32, height: u32, bsp: BspConfig, rooms: RoomConfig, connect: ConnectConfig }(+Default).enum ConfigError { /* e.g. ZeroDimension, RoomLargerThanLeaf, ... */ }(implstd::error::Error/Display).fn dungeon(cfg: DungeonConfig) -> Result<Pipeline, ConfigError>.
Tests (integration — spec §9)
- Determinism:
dungeon(cfg)?.run(42)twice produces equalMaps and identicalto_ascii(). run==run_with_snapshots: same seed yields the sameMap; snapshot count == 5.- Connectivity: flood-fill the
Floor/Doortiles of a generated dungeon; assert everyRoomregion's interior is reachable (no orphaned rooms). - Bounds: no non-
Walltile lies outside the map; all rooms within bounds. - Config validation: zero dimensions and a room-min-size larger than
min_leafboth returnErr(ConfigError), not a panic. - Door reachability sanity: at least one
Doortile exists in a multi-room dungeon, and connected edges haveat == Some(_). - (Optional) print one ASCII dungeon in a
#[test]behind--nocapturefor eyeball confirmation.
Success Criteria
dungeon(cfg)validates config and returns aPipeline(orConfigError) assembling all five passes in order.- A generated dungeon is fully connected, in-bounds, deterministic, and has doors.
runandrun_with_snapshotsagree; snapshot count is 5.- Module declarations added to
lib.rs/recipes/mod.rs. - All tests pass:
cargo test -p reikhelm-core(full suite green)
Commit
"feat(core): dungeon recipe + end-to-end integration tests"