Skip to main content

A procedural dungeon map generator for tabletop RPGs

Project description

Dungeongen

A procedural dungeon generation and rendering system for tabletop RPG maps.

Temple Dungeon

๐ŸŽฎ 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 rooms
  • SMALL - 6-10 rooms
  • MEDIUM - 10-20 rooms
  • LARGE - 20-35 rooms
  • XLARGE - 35-50 rooms

Symmetry Types

  • NONE - Asymmetric layout
  • BILATERAL - Mirror symmetry (left/right)
  • RADIAL_2 - 180ยฐ rotational symmetry (future)
  • RADIAL_4 - 90ยฐ rotational symmetry (future)

Water Depth

  • DRY - No water
  • PUDDLES - ~45% coverage
  • POOLS - ~65% coverage
  • LAKES - ~82% coverage
  • FLOODED - ~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.

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.


Example Dungeon

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dungeongen-0.1.12.tar.gz (469.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dungeongen-0.1.12-py3-none-any.whl (501.3 kB view details)

Uploaded Python 3

File details

Details for the file dungeongen-0.1.12.tar.gz.

File metadata

  • Download URL: dungeongen-0.1.12.tar.gz
  • Upload date:
  • Size: 469.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for dungeongen-0.1.12.tar.gz
Algorithm Hash digest
SHA256 a287012a5b4019e6f401a1d58753a0f0ce25915b5040b1ade3c7b32cc58363a5
MD5 48e9f75df65052ef600414249f42df4a
BLAKE2b-256 14b2fb009669296849c2a68b2c0356d979d491baec328e9bac91c650d86d1df4

See more details on using hashes here.

File details

Details for the file dungeongen-0.1.12-py3-none-any.whl.

File metadata

  • Download URL: dungeongen-0.1.12-py3-none-any.whl
  • Upload date:
  • Size: 501.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for dungeongen-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 5e135b42901c67acaecc72b9845eea4b37d6132e1bf7b61d2f6ae72c0209f9c5
MD5 9ebc850e2438ef41f79502b33ebe69b6
BLAKE2b-256 068c28d7e20ef2561f77e66a090bf8c855ba688c4d6cff66d64a34a7828f7e95

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page