This is what we’ve been building toward. All the geometry infrastructure — Factory, Resolvers, building shells — exists to support this: procedurally generating dungeons at runtime.

Castle Dracula (the hand-authored test)

Started the day by building a hand-authored 5-floor dungeon layout to validate that the geometry system handles vertical space. Stacked rooms, staircases between floors, CSG negate operations for inter-floor openings. We called it Castle Dracula because naming things is more fun when you don’t overthink it.

It worked, which meant we could start generating layouts instead of authoring them.

PathGraph: The first generator

The first procedural generator used an incremental path approach:

  1. Place a starting room
  2. Pick a random direction (north, south, east, west)
  3. Place a new room adjacent to the last one
  4. Repeat, occasionally branching

Simple algorithm, hard to get right. The first version immediately produced overlapping rooms because the overlap check only tested along the movement axis. Room A extends east, Room B extends south from A — but B’s footprint extends into a room that was placed three steps ago. You have to check against all existing rooms, not just the most recent one.

We fixed the overlap bug, then added multi-level support (rooms placed above or below the current floor), then fixed the Y-axis overlap check (the RoomBlocker wasn’t including vertical extent in its collision test).

Horizon scanning

The day’s breakthrough was replacing random direction picking with horizon scanning. The generator maintains a frontier — every open face of every placed room where a new room could potentially go. Instead of blindly picking a direction from the last room, it scans all open faces across all rooms, filters out positions that would cause overlap, and picks from the valid options.

This produces dramatically better layouts. Rooms cluster together with shared walls, creating dense, interconnected spaces instead of long snaking corridors. The horizon naturally guides growth outward from the center rather than wandering in one direction.

The scan also enables configurable generation: want a linear dungeon? Only pick from the frontier faces furthest from the start. Want a dense cluster? Pick uniformly. Want branching corridors? Prefer faces on rooms that have few neighbors.

Six commits, three algorithmic approaches, and the generator finally produces layouts that look like dungeons instead of random walks. The foundation is solid — tomorrow we start making the rooms walkable.