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

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
import skia

# 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
width, height = 1200, 1200
surface = skia.Surface(width, height)
canvas = surface.getCanvas()
canvas.clear(skia.Color(255, 255, 255))

transform = dungeon_map._calculate_default_transform(width, height)
dungeon_map.render(canvas, transform)

image = surface.makeImageSnapshot()
image.save('my_dungeon.png', skia.kPNG)

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
  • RADIAL_4 - 90° rotational symmetry (4-fold)

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.

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.


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.2.tar.gz (463.8 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.2-py3-none-any.whl (495.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for dungeongen-0.1.2.tar.gz
Algorithm Hash digest
SHA256 86765a298f011fdbb712d8515e0e296b9f57e9607f4637c5641f50c569da928c
MD5 3f73d88fbedfdd734f9cdf0f35ad54b7
BLAKE2b-256 73194ee2ae16a728d03f73ebd642510ab752841cd8a1c7870ac10c7d4545b91f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for dungeongen-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 65628a2a4b4389f26b92598bd4b833bbbc22f09f3ae3a66df0bb526f84422694
MD5 f625e7b0eab94fc06bfd23c99bd88520
BLAKE2b-256 7010fc2483b01f041756ce1696550f66dc2a1ff77bdf46c32ad4f14c6c4fc123

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