Skip to content

Packs / game-assets-and-ai-public

procedural-level-generator

Generate dungeon/room levels procedurally (BSP rooms + corridors) from a seed, export Tiled-compatible JSON, and verify every floor tile is reachable

L2 Checks passed 3 of 3 runsv1.0.0Tech-Realm/space-game-assets-and-ai-public

Install

logicpacks pack use game-assets-and-ai-public/procedural-level-generator
get_pack game-assets-and-ai-public/procedural-level-generator

The second line is the MCP tool call for the LogicPacks connector (Claude Code, Codex, Claude.ai and others). The first run of a pack someone else wrote asks for your yes.

Keys it needs (names only)

None.

Playbooks included

  • Spec: spec/SPEC.md (goal, steps, edge cases, don’ts)
  • Routes: local-python
  • Checks: 2 in outcome/checks.yaml
  • Code: levelgen.pyverify_level.py
  • Tools: python3

Usage, last 8 weeks

New: no recorded use yet.

Purpose (from spec/SPEC.md)

Goal

Endless playable layouts for a 2D game: deterministic from a seed, loadable by Phaser/Tiled, never with unreachable rooms.

Steps

  1. Run python3 code/levelgen.py --seed 42 --w 64 --h 48 --out out/level.json (Tiled JSON: one tile layer, 1 = floor, 2 = wall; plus an object layer with spawn and exit).
  2. Load in Phaser: this.load.tilemapTiledJSON('lvl', 'level.json').
  3. Verify: python3 code/verify_level.py out/level.json (flood fill from spawn reaches all floor and the exit).
  4. Tune room sizes/min split in the constants at the top.

Edge cases

  • Tiny maps can't fit the minimum rooms: the generator raises instead of making a broken map.
  • Same seed + same version = same map: store the seed with the save game.

Don'ts

  • Don't place spawn and exit in the same room.
  • Don't ship a level without running the reachability check.