Procedural Level Generation: From BSP to WFC
Roguelite without procedural generation is not roguelite. Survival-sandbox with fixed maps loses replayability. Our team of engineers with 10+ years of experience in game development (50+ level generation projects) knows: procedural generation is an architectural decision that requires serious design. Done carelessly, it generates "junk" levels: impassable corridors, isolated rooms, boring uniformity. We help configure generation so it works stably and fast. Order turnkey setup — get a ready module with quality control that reduces content development costs by 40–60% and pays for itself in 3 months. Contact us to assess your project.
Key Approaches to Generation
BSP (Binary Space Partitioning)
Recursive division of space into rectangular sections, each containing a room, with corridors connecting them. Classic dungeon crawler. Advantage: guaranteed passability. Disadvantage: rectangular monotony without additional post-processing. More details: BSP.
Wave Function Collapse (WFC)
Algorithm using compatibility constraints between tiles. Each cell has a set of possible states; when a state is chosen, neighboring cells receive constraints. The result is organic structures with high quality control through a set of rules. WFC generates levels 2x faster than manual development. Works with 2D tiles and 3D voxel structures. More details: WFC.
Noise-based terrain
For open worlds: Perlin noise, Simplex Noise, or Domain-Warped FBM. Unity Terrain with TerrainData.SetHeights() accepts a 2D float array — height generation via noise is done in 30 lines of code. Complexity begins with biomes: transitions, object placement, density control. Terrain generation requires curve tuning for vertical zones.
Grammar-based generation
For narrative levels with mandatory events: the progression graph is described via rules, the generator builds a level ensuring that graph. Used in action-roguelite where dramaturgy is important.
How to Choose a Generation Algorithm?
The choice depends on genre and platform. BSP suits dungeons with rectangular rooms, WFC for organic structures with clear rules, Perlin noise for large open worlds. For 2D dungeon crawler with procedural map generation, BSP is optimal; for roguelite with tile-based world, WFC; for survival-sandbox, noise-based with biomes. We will analyze your requirements and propose the optimal solution. Get a consultation — we will select an algorithm for your project.
Why Quality Control Matters?
Generation without validation is a source of bugs. Three main problems: passability guarantee, excessive uniformity, empty or overcrowded zones. Solution: flood fill/A* check, anchor rooms, Poisson Disk Sampling. This reduces defective levels by 90% and lowers testing costs. Level validation should be automated: after each generation, a script runs checking passability and object density.
More on passability check
Flood fill from the entry point fills all reachable tiles. If a key point (exit, boss) is not filled, the level is rejected. A* gives exact path but is slower. For mobile platforms, flood fill is faster and sufficient. Regeneration threshold: no more than 16 ms, otherwise the player will notice the delay.The Hardest Part — Quality Control
Generation works, but not every generated level is "good". Three problems that always occur:
-
Passability guarantee. Flood fill or pathfinding (A*) from the entry point to all key points (exit, mandatory items, bosses). If pathfinding does not find a path — regeneration. Important: regeneration must be fast (< 16 ms on mobile), otherwise the player sees a loading delay.
-
Excessive uniformity. WFC and BSP without additional rules give a "bland" result — no accents, no interesting places. Solution: explicit anchor rooms (anchor rooms): start room, boss room, secret room — generated from fixed templates and placed in mandatory positions. The rest is procedural.
-
Too empty or too filled levels. Object placement (enemies, items, traps) cannot be pure random — you get either a desert or an impassable cluster. A working approach: Poisson Disk Sampling for even distribution with minimum distance between objects plus weight coefficients by room type and distance from start.
Example Implementation in Unity
Typical architecture for a 2D dungeon generator:
LevelGenerator
├── RoomGenerator — BSP / templates
├── CorridorConnector — room connections
├── ValidityChecker — flood fill passability
├── PopulationSystem — object placement
└── TilemapPainter — write to Tilemap
LevelGenerator receives LevelConfig (ScriptableObject with seed, dimensions, parameters) and returns LevelData — room graph with metadata. TilemapPainter renders LevelData into Tilemap with the required tile set. Separation of generation and rendering allows using one generator for different visual themes (dungeon, cave, ship).
Seed for reproducibility. Random.InitState(seed) before generation — the same seed always gives the same level. This is needed for: sharing levels between players (Daily Run in roguelite), debugging a specific level, server-side pass validation.
Generation Performance
On mobile devices, generation must fit into the loading screen. Benchmarks:
| Level size | Generation time | Comment |
|---|---|---|
| 50×50 tiles (BSP + population) | 5–20 ms | On mid-range Android |
| 200×200 tiles | 50–200 ms | Requires chunking with async |
| Terrain 512×512 (Perlin noise) | 50–200 ms | Must be async/Thread |
Unity Job System allows moving noise generation computations into burst-compiled jobs — 5–10x speedup over managed code. Our team uses Job System to achieve 70% reduction in generation time.
Stages of Work
- Requirements analysis — generation type based on genre and mechanics.
- Algorithm prototype — quick validation of approach without final art.
- Quality control — level validator, rule iteration.
- Content integration — tilesets, anchor room templates.
- Performance — profiling, async, Job System.
- Parameterization — configs for game designer (difficulty, size, density).
What's Included
- Analysis of your project and game design documentation
- Development and tuning of the generation algorithm
- Integration into your engine (Unity, Unreal)
- Level quality validation
- Documentation and team training
- Post-launch support
Estimated Timelines
| Scale | Timeline |
|---|---|
| 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 is calculated individually after analyzing the genre, platform and level variety requirements. Contact us to discuss your project and get an estimate.





