Dungeongen
A procedural dungeon generation and rendering system for tabletop RPG maps.
๐ฎ Try it Online
dungeongen-web.onrender.com - No installation required!
Quick Start
pip install dungeongen
python -m dungeongen.webview.app
Then open http://localhost:5050 in your browser to generate dungeons interactively.
Features
Layout Generation
- Procedural room placement with configurable room sizes and shapes (rectangular, circular)
- Intelligent passage routing that connects rooms with hallways
- Symmetry modes: None, Bilateral (mirror)
- Configurable density: Sparse, Normal, Tight packing
- Automatic door placement with open/closed states
- **Stairs and dungeon exiโฆ
Dungeongen
A procedural dungeon generation and rendering system for tabletop RPG maps.
๐ฎ Try it Online
dungeongen-web.onrender.com - No installation required!
Quick Start
pip install dungeongen
python -m dungeongen.webview.app
Then open http://localhost:5050 in your browser to generate dungeons interactively.
Features
Layout Generation
- Procedural room placement with configurable room sizes and shapes (rectangular, circular)
- Intelligent passage routing that connects rooms with hallways
- Symmetry modes: None, Bilateral (mirror)
- Configurable density: Sparse, Normal, Tight packing
- Automatic door placement with open/closed states
- Stairs and dungeon exits
Rendering
- Hand-drawn aesthetic with crosshatch shading and organic lines
- Water features with procedural shorelines and ripple effects
- Room decorations: columns, altars, fountains, dais platforms, rocks
- High-quality SVG and PNG output
- Grid overlay for tabletop play
Water System
Procedural water generation using noise-based field generation:
- Depth levels: Dry, Puddles, Pools, Lakes, Flooded
- Organic shorelines using marching squares with Chaikin smoothing
- Ripple effects that follow contour curves
Project Structure
dungeongen/
โโโ src/dungeongen/ # Main package
โ โโโ layout/ # Dungeon layout generation
โ โ โโโ generator.py # Main procedural generator
โ โ โโโ models.py # Room, Passage, Door data models
โ โ โโโ params.py # Generation parameters
โ โ โโโ validator.py # Layout validation
โ โ
โ โโโ map/ # Map rendering system
โ โ โโโ map.py # Main renderer
โ โ โโโ room.py # Room rendering
โ โ โโโ passage.py # Passage rendering
โ โ โโโ water_layer.py # Water generation
โ โ โโโ _props/ # Decorations (columns, altars, etc.)
โ โ
โ โโโ drawing/ # Drawing utilities
โ โ โโโ crosshatch.py # Crosshatch shading
โ โ โโโ water.py # Water rendering
โ โ
โ โโโ algorithms/ # Generic algorithms
โ โ โโโ marching_squares.py # Contour extraction
โ โ โโโ chaikin.py # Curve smoothing
โ โ โโโ poisson.py # Poisson disk sampling
โ โ
โ โโโ graphics/ # Graphics utilities
โ โ โโโ noise.py # Perlin noise, FBM
โ โ โโโ shapes.py # Shape primitives
โ โ
โ โโโ webview/ # Interactive web preview
โ โโโ app.py # Flask application
โ โโโ templates/ # HTML templates
โ
โโโ tests/ # Test suite
โโโ docs/ # Documentation
โโโ pyproject.toml # Package configuration
Installation
From PyPI
pip install dungeongen
From Source (for development)
git clone https://github.com/benjcooley/dungeongen.git
cd dungeongen
pip install -e .
Dependencies
- Python 3.10+
- skia-python (rendering)
- numpy (noise generation)
- Flask (web preview)
- rich (logging)
Usage
Web Preview
python -m dungeongen.webview.app
Then open http://localhost:5050 in your browser.
Python API
from dungeongen.layout import DungeonGenerator, GenerationParams, DungeonSize, SymmetryType
from dungeongen.webview.adapter import convert_dungeon
from dungeongen.map.water_layer import WaterDepth
# Configure generation
params = GenerationParams()
params.size = DungeonSize.MEDIUM
params.symmetry = SymmetryType.BILATERAL
# Generate layout
generator = DungeonGenerator(params)
dungeon = generator.generate(seed=42)
# Convert to renderable map with water
dungeon_map = convert_dungeon(dungeon, water_depth=WaterDepth.POOLS)
# Render to PNG or SVG
dungeon_map.render_to_png('my_dungeon.png')
dungeon_map.render_to_svg('my_dungeon.svg')
Configuration Options
Dungeon Size
TINY- 4-6 roomsSMALL- 6-10 roomsMEDIUM- 10-20 roomsLARGE- 20-35 roomsXLARGE- 35-50 rooms
Symmetry Types
NONE- Asymmetric layoutBILATERAL- Mirror symmetry (left/right)RADIAL_2- 180ยฐ rotational symmetry (future)RADIAL_4- 90ยฐ rotational symmetry (future)
Water Depth
DRY- No waterPUDDLES- ~45% coveragePOOLS- ~65% coverageLAKES- ~82% coverageFLOODED- ~90% coverage
Acknowledgments
This project was inspired by watabouโs One Page Dungeon, a fantastic procedural dungeon generator. The hand-drawn crosshatch aesthetic and overall visual style draw heavily from watabouโs work.
- One Page Dungeon Generator: https://watabou.itch.io/one-page-dungeon
- watabouโs other generators: https://watabou.itch.io/
Differences from One Page Dungeon
This is a complete rewrite in Python, not a port. Options do not work identically as this is a completely different codebase. Key differences:
Not yet implemented:
- Only bilateral (mirror) symmetry is supported; linear, radial, and other layout modes are planned
- Some props are missing (casket, star, podium, curtains, barrels)
- Various bugs and edge cases - not everything works perfectly
Will not be added:
- Auto-rotate transform for diagonal map views - this library outputs maps for further processing
- Auto-generated text, titles, and descriptions - this is a map generator, not a complete document generator. That being said youโre welcome to add your own dungeon bits
License
MIT License - See LICENSE file for details.