Setting up procedural level generation in games

Our video game development company runs independent projects, jointly creates games with the client and provides additional operational services. Expertise of our team allows us to cover all gaming platforms and develop an amazing product that matches the customer’s vision and players preferences.
Showing 1 of 1 servicesAll 242 services
Setting up procedural level generation in games
Complex
~10 business days
FAQ
Our competencies
What are the stages of Game Development?
Latest works
  • image_games_mortal_motors_495_0.webp
    Game development for Mortal Motors
    663
  • image_games_a_turnbased_strategy_game_set_in_a_fantasy_setting_with_fire_and_sword_603_0.webp
    A turn-based strategy game set in a fantasy setting, With Fire and Sword
    859
  • image_games_second_team_604_0.webp
    Game development for the company Second term
    490
  • image_games_phoenix_ii_606_0.webp
    3D animation - teaser for the game Phoenix 2.
    533

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

  1. Analyze requirements — generation type for genre and mechanics
  2. Algorithm prototype — quick approach check without final art
  3. Quality control — level validator, rule iteration
  4. Content integration — tilesets, anchor room templates
  5. Performance — profiling, async, Job System
  6. 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.