Skip to content

Procedural level generator

Vicious Squid edited this page Jun 3, 2026 · 13 revisions

Tools Menu > Procedural Generator

Procedurally generates fully-playable liminal spaces with customisable size, rooms and monsters

Completely unique every time the "Generate" button is clicked...

  • Click the PLAY button to play instantly
    or
  • Edit the map as you like (add/remove entities and brushes)

Algorithm overview:

The generator uses a grid‑based room placement algorithm:

  1. Divide the world into cells of size 64×64 units.

  2. Randomly place rectangular rooms of varying sizes.

  3. Connect rooms using A* pathfinding with optional waypoints and dead‑ends.

  4. Build geometry brushes (walls, floors, ceilings, corner pillars) with nodraw optimisation.

  5. Populate the map with:

    • Ambient lights in each room.

    • Player start point.

    • Exit portal (level changer) - (currently broken)

    • Optional monsters (flying or humanoid).

    • Optional health pickups (placed away from monsters).


The CLI version (tools/procedural_map_gen.py) runs without a GUI and saves the map directly.

Basic example:

python tools/procedural_map_gen.py -o my_map.json --size large --room-count 18

All options:

usage: procedural_map_gen.py -o OUTPUT [options]

Required:
  -o OUTPUT, --output OUTPUT   Output JSON file

Map size:
  --size {small,medium,large}  Preset (default: medium)
  --width WIDTH                Custom width (ignored if --size used)
  --height HEIGHT              Custom height

Room generation:
  --room-count N               Target rooms (8-24, default: 14)
  --min-room N                 Min room size in units (default: 256)
  --max-room N                 Max room size in units (default: 384)

Textures:
  --wall-tex NAME              Wall texture file (default: default.png)
  --floor-tex NAME             Floor texture file (default: default.png)

Monsters:
  --spawn-monsters             Enable monsters (default: on)
  --no-spawn-monsters          Disable monsters
  --monster-count N            Number of monsters (default: 4)

Health pickups:
  --spawn-health               Enable health (default: on)
  --no-spawn-health            Disable health
  --health-count N             Number of health items (default: 6)

Random seed:
  --seed N                     Fixed seed for reproducible maps

Full example with custom size and fixed seed:

python tools/procedural_map_gen.py -o map_seed123.json \
    --width 4096 --height 4096 \
    --room-count 20 \
    --min-room 320 --max-room 512 \
    --monster-count 8 \
    --health-count 10 \
    --seed 123

Information on the structure of map files is available on the map format page

Clone this wiki locally