D&D 5e creature combat simulator with web UI, AI analysis, and SRD rules https://dndsim.gi7b.org/
  • Python 82.6%
  • JavaScript 8.4%
  • CSS 6%
  • HTML 2.9%
  • Dockerfile 0.1%
Find a file
2026-07-09 23:25:11 +08:00
5E srd Add SRD rules/how-to tabs, combat audit, engine fixes, map replay, and web UI enhancements 2026-07-09 22:49:04 +08:00
prompts Web app + AI integration: FastAPI, DeepSeek analyzer, frontend, Docker 2026-06-09 23:55:36 +08:00
static Add SRD rules/how-to tabs, combat audit, engine fixes, map replay, and web UI enhancements 2026-07-09 22:49:04 +08:00
templates Add SRD rules/how-to tabs, combat audit, engine fixes, map replay, and web UI enhancements 2026-07-09 22:49:04 +08:00
.env.example Web app + AI integration: FastAPI, DeepSeek analyzer, frontend, Docker 2026-06-09 23:55:36 +08:00
.gitignore PC crash recovery: structured logger, simulate_web(), engine hooks, PLAN, docs 2026-06-09 21:54:54 +08:00
abilities.py Add SRD rules/how-to tabs, combat audit, engine fixes, map replay, and web UI enhancements 2026-07-09 22:49:04 +08:00
AGENTS.md Document Docker deployment in README and AGENTS 2026-07-09 23:25:11 +08:00
ai_analyzer.py Web app + AI integration: FastAPI, DeepSeek analyzer, frontend, Docker 2026-06-09 23:55:36 +08:00
AUDIT.md Add SRD rules/how-to tabs, combat audit, engine fixes, map replay, and web UI enhancements 2026-07-09 22:49:04 +08:00
behavior.py Add SRD rules/how-to tabs, combat audit, engine fixes, map replay, and web UI enhancements 2026-07-09 22:49:04 +08:00
creature.py Add SRD rules/how-to tabs, combat audit, engine fixes, map replay, and web UI enhancements 2026-07-09 22:49:04 +08:00
definitions.py resync 2021-11-24 22:47:29 +02:00
dice.py fix weapon select 2020-03-27 23:22:43 +02:00
docker-compose.yml Embed DeepSeek API key in docker-compose.yml 2026-06-09 23:58:58 +08:00
Dockerfile Web app + AI integration: FastAPI, DeepSeek analyzer, frontend, Docker 2026-06-09 23:55:36 +08:00
extract_srd.py Add SRD rules/how-to tabs, combat audit, engine fixes, map replay, and web UI enhancements 2026-07-09 22:49:04 +08:00
main.py Add SRD rules/how-to tabs, combat audit, engine fixes, map replay, and web UI enhancements 2026-07-09 22:49:04 +08:00
mechanics.py Add SRD rules/how-to tabs, combat audit, engine fixes, map replay, and web UI enhancements 2026-07-09 22:49:04 +08:00
messages.py PC crash recovery: structured logger, simulate_web(), engine hooks, PLAN, docs 2026-06-09 21:54:54 +08:00
PLAN-web-ai-integration.md PC crash recovery: structured logger, simulate_web(), engine hooks, PLAN, docs 2026-06-09 21:54:54 +08:00
PROGRESS.md Document Docker deployment in README and AGENTS 2026-07-09 23:25:11 +08:00
RCA-001-Undefined-Team-Roster-and-Backend-Category-Mismatch.md RCA-001 fix: separate source (npc/pc) from category (beast/undead) 2026-06-10 00:30:02 +08:00
README.md Document Docker deployment in README and AGENTS 2026-07-09 23:25:11 +08:00
requirements.txt Web app + AI integration: FastAPI, DeepSeek analyzer, frontend, Docker 2026-06-09 23:55:36 +08:00
structured_logger.py Add SRD rules/how-to tabs, combat audit, engine fixes, map replay, and web UI enhancements 2026-07-09 22:49:04 +08:00
ui.py Add Textual TUI (ui.py) for creature browser, encounter builder, and combat log 2026-06-09 00:22:10 +08:00
weapons.py fix stomach, special attacks and regeneration 2021-11-22 00:47:05 +02:00
web_app.py Add SRD rules/how-to tabs, combat audit, engine fixes, map replay, and web UI enhancements 2026-07-09 22:49:04 +08:00
world.py improve main 2021-11-23 03:27:29 +02:00

DnD5e-CombatSimulator

D&D 5e Creature Combat Simulator

A Python tool for simulating Dungeons & Dragons 5th edition encounters between creatures. The core engine runs on Python 3.6+ with no external dependencies; the web UI and AI analysis layer run in a Docker container on Python 3.12.

Why does this exist?

This script is mainly created as a DM tool for simulating encounters between different types of creatures. Want to know how a level 8 Barbarian with a magical Greataxe +2 and his Dire Wolf companion can stand against a Mammoth? How about a Purple Worm vs. 30 zombies? Just run the script and see.

The fastest way to run the full simulator with the web interface and AI analysis is via Docker Compose.

1. Clone the repo

git clone https://git.gi7b.org/justin-admin/DnD5e-CombatSimulator.git
cd DnD5e-CombatSimulator

2. Configure environment variables

Copy the example environment file and add your DeepSeek API key:

cp .env.example .env

Edit .env:

DEEPSEEK_API_KEY=sk-...
PORT=7681
HOST=0.0.0.0

The DeepSeek key is required for the AI Analysis panel in the web UI. The rest of the simulator works without it.

3. Build and run

docker compose up -d

The web UI is available at http://localhost:7681.

4. Check health

curl http://localhost:7681/api/health

5. Stop

docker compose down

Production deployment

This project is deployed as a Docker service on PC02 (192.168.196.189), port 7681, and exposed publicly at:

https://dndsim.gi7b.org

Nginx Proxy Manager on PC03 terminates SSL and proxies to PC02:7681. To redeploy the live instance:

  1. Push changes to git.gi7b.org/justin-admin/DnD5e-CombatSimulator.
  2. On PC02, pull the latest code in /home/user/docker/dndsim/.
  3. Rebuild and restart the container:
    cd /home/user/docker/dndsim
    docker compose down
    docker compose up -d --build
    
  4. Verify: curl http://localhost:7681/api/health should return 200.

Running locally without Docker

For the original command-line simulator only (no web UI, no AI analysis):

python3 main.py

Run simulate() in main.py to start a simulation. Call list_creatures() to see implemented creatures. More documentation is in main.py.

Web UI features

  • Creature browser with full stat blocks
  • Team builder for arbitrary party sizes
  • Combat simulation with detailed log
  • Animated map replay with turn slider
  • SRD rules and how-to tabs
  • AI analysis panel (DeepSeek API key required)

Features

  • Movement in two-dimensional world (flying/burrowing not yet implemented)
  • Possibility to create battles between parties of arbitrary size
  • Create approximations of player characters by combining already defined creature, ability and weapon objects (see definitions.py)
  • Most of the crucial D&D mechanics defined

Caveats

Creature behavior is very straightforward. Thus the results are not always comparable one-to-one to Pen & Paper encounters.

Known bugs

  • If a creature has swallowed other creatures and dies, the swallowed creatures end up in the same coordinates.

TODO

  • Spell casting
  • Flying and burrowing
  • More creatures
  • Implement creature size on the map (now all take same amount of space)