Procedural Level Generation Setup
Roguelite without procedural generation — not roguelite. Survival-sandbox with fixed maps — loses replayability after first hours. Procedural generation is not trendy term, it's architectural decision requiring serious design. Done carelessly, generates "garbage" levels: impassable corridors, isolated rooms, boring uniformity instead of interesting variety.
Key generation approaches
BSP (Binary Space Partitioning). Recursive space division into rectangular sections, each section — room, between rooms — corridors. Classic dungeon crawler: Rogue, NetHack. Plus — guaranteed passability. Minus — rectangular monotony without extra post-processing.
Wave Function Collapse (WFC). Algorithm using compatibility constraints between tiles. Each cell has set of allowed states; choosing state restricts neighbor cells. Result — organic structures with high quality control via rule set. Works with 2D-tiles and 3D-voxel structures. In Unity ready implementations on GitHub (mxgmn/WaveFunctionCollapse), engine support via TilemapRule.
Noise-based terrain. For open worlds — Perlin Noise, Simplex Noise or modern Domain-Warped FBM (Fractional Brownian Motion). Unity Terrain with TerrainData.SetHeights() takes 2D float array — height generation via noise in 30 lines of code. Complexity starts with biomes: transitions between biomes, object placement by biome, density control.
Grammar-based generation. For narrative levels with mandatory events: passage graph described via rules (start → combat → loot → boss → exit), generator builds level ensuring this graph. Applied in action-roguelite where progression drama matters, not just variety.
Most complex part — quality control
Generation works but not every generated level is "good." Three problems always arise:
Passability guarantee. Flood fill or pathfinding (A*) from entry to all key points (exit, mandatory items, bosses). If pathfinding doesn't find path — regenerate. Important: regeneration must be fast (< 16ms on mobile), else player sees load lag.
Excessive uniformity. WFC and BSP without extra rules give "bland" result — no accents, no interesting spots. Solution: explicit "anchor" points: starter room, boss-room, secret room — generated from fixed templates and placed at mandatory positions. Rest — procedural.
Too empty or too packed levels. Object placement (enemies, items, traps) can't be pure random — results in desert or impassable mess. Working approach: Poisson Disk Sampling for uniform distribution with minimum distance between objects + weight coefficients by room type and distance from start.
Example implementation on Unity
Typical 2D dungeon-generator architecture:
LevelGenerator
├── RoomGenerator — BSP / templates
├── CorridorConnector — connect rooms
├── ValidityChecker — flood fill passability
├── PopulationSystem — place objects
└── TilemapPainter — write to Tilemap
LevelGenerator takes LevelConfig (ScriptableObject with seed, sizes, params) and returns LevelData — room graph with metadata. TilemapPainter renders LevelData into Tilemap with needed tile set. Separating generation from rendering lets use one generator for different visual themes (dungeon, cave, ship).
Seed for reproducibility. Random.InitState(seed) before generation — same seed always gives same level. Needed for: level sharing between players (Daily Run in roguelite), debugging specific level, server-side validation of completion.
Generation performance
On mobile devices generation must fit into loading screen. Guidelines:
- 50×50 tile level (BSP + population) — 5–20ms on average Android
- 200×200 tile level — needs chunk-splitting with async generation
- Terrain 512×512 via Perlin Noise — 50–200ms, must be async/Thread
Unity Job System lets move noise-generation calculations to burst-compiled job — 5–10x acceleration vs managed code.
Work stages
- Analyze requirements — generation type for genre and mechanics
- Algorithm prototype — quick approach check without final art
- Quality control — level validator, rule iteration
- Content integration — tilesets, anchor room templates
- Performance — profiling, async, Job System
- Parameterization — configs for designer (difficulty, size, density)
| Scale | Duration |
|---|---|
| Basic BSP dungeon-generator (2D) | 2–4 weeks |
| WFC-generator with quality control | 4–8 weeks |
| Noise-based open world with biomes | 6–12 weeks |
Cost determined after analyzing genre, platform, and level variety requirements.





