A procedural dungeon map generator for tabletop RPGs
Project description
Dungeongen
A procedural dungeon generation and rendering system for tabletop RPG maps.
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
- Multiple symmetry modes: None, Bilateral (mirror), Radial-2, Radial-4
- Dungeon archetypes: Classic, Warren, Temple, Crypt, Lair
- 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 symmetryRADIAL_4- 90° rotational symmetry (4-fold)
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/
- Source code (Haxe): https://github.com/watabou/one-page-dungeon
Note: This project is a complete rewrite in Python, not a port. While inspired by watabou's visual style and procedural generation concepts, the algorithms and implementation are original.
License
MIT License - See LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dungeongen-0.1.5.tar.gz.
File metadata
- Download URL: dungeongen-0.1.5.tar.gz
- Upload date:
- Size: 468.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
015175dd847c550cec48bd46f6436fd0d1e7123adaa17a502963f76c564d7a3e
|
|
| MD5 |
0e987c07bd88db7b6d0ac391cd9c6990
|
|
| BLAKE2b-256 |
a1ecc6fd17a088404d092c9945205bdf46f6dec05a482327884209a2092fb0f9
|
File details
Details for the file dungeongen-0.1.5-py3-none-any.whl.
File metadata
- Download URL: dungeongen-0.1.5-py3-none-any.whl
- Upload date:
- Size: 500.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
684cf7666dcdfd3106ff3adda802031a50a58fd51b942218427bdcd1b5e826c8
|
|
| MD5 |
2e8ea76a635f97fd81d53cbceb1505ee
|
|
| BLAKE2b-256 |
03a8608fe3a7d73e4e3e4cc5ca7de825d9767795bbcc5c5c28488f91681d5956
|