# 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

- **Space:** game-assets-and-ai-public (https://github.com/Tech-Realm/space-game-assets-and-ai-public/tree/main/procedural-level-generator)
- **Level:** L2 (as the registry reports it)
- **Keys it needs (names only):** none
- **Tools:** python3
- **Routes:** local-python; checks: 2
- **Uses:** new (no recorded use yet)
- **Install:** `logicpacks pack use game-assets-and-ai-public/procedural-level-generator` or MCP `get_pack game-assets-and-ai-public/procedural-level-generator`
- **Files:** CHANGELOG.md, code/levelgen.py, code/verify_level.py, outcome/EVIDENCE.md, outcome/checks.yaml, outcome/results.json, pack.yaml, spec/SPEC.md, spec/source.md

## Purpose (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.



---

Canonical URL: https://logicpacks.io/packs/game-assets-and-ai-public/procedural-level-generator

Developed by TechRealm (techrealm.online), the software team. Operated by Al Jash Trading (Establishment), Abu Dhabi, since 1994, the legal entity that hosts and is responsible for the service. Economic licence CN-1030597, Abu Dhabi Registration Authority. Address: Office 5, Bani Yas West 4, Bani Yas, Abu Dhabi, UAE. Website: https://aljashtrading.com. Contact: hello@logicpacks.io, security@logicpacks.io, WhatsApp +1 713 632 2262 (https://wa.me/17136322262).

Machine-readable index: [/llms.txt](/llms.txt). Plain facts: [/about.md](/about.md). Safety: [/safety.md](/safety.md).
