Skip to main content

Dwarf Fortress storytelling assistant — turns game events into narrative stories

Project description

df-storyteller

A storytelling companion for Dwarf Fortress. Captures game events, dwarf personalities, and world history through DFHack, then generates AI-written narratives grounded in your actual gameplay.

Python 3.11+ License

Full Documentation on the Wiki

Features

Narrative Generation

  • Fortress Chronicles — Seasonal narratives tracking what's changing in your fortress
  • Dwarf Diaries — First-person journal entries shaped by personality, beliefs, and stress
  • Character Biographies — Dated entries that evolve as dwarves change over time
  • Death Eulogies — Memorial narratives for fallen dwarves
  • Battle Reports — Dramatic combat accounts written by survivors or the fortress chronicler
  • Epic Sagas — World history narratives from legends data
  • Fortress Gazette — A dwarven newspaper with five sections, written by the fortress's best writer

Quest System

  • AI-Generated Quests — Based on your actual fortress state, grounded in real DF mechanics
  • Narrative-Driven — Quests that drive the story (character arcs, threats, faith, ambition)
  • Difficulty Tiers — Easy, Medium, Hard, Legendary
  • Completion Narratives — AI writes how the quest was fulfilled, feeds into future chronicles

Visualization & Data

  • Relationship Web — Interactive force-directed graph of fortress connections
  • Pantheon — Deity worship chart with sphere descriptions from legends
  • Combat Log — Blow-by-blow fight details with siege grouping
  • Chat Log — Dwarf conversations with AI social summaries
  • Lore Browser — Searchable world history with hover tooltips (kill counts, battle forces, relationships)
  • Live Event Feed — Real-time game events via WebSocket

Screenshots

Chronicle

Chronicle

Dwarves

Dwarves

Relationship Web

Relationship Web

Pantheon

Pantheon

Events

Events

Lore

Lore

Quests

Quests

Gazette

Gazette

Quick Start

Install and run:

pip install df-storyteller
python -m df_storyteller init
python -m df_storyteller serve

In DFHack console (first time per fortress):

storyteller-begin

Or install from source:

git clone https://github.com/Been012/df-storyteller.git
cd df-storyteller
pip install -e .
python -m df_storyteller init
python -m df_storyteller serve

Requirements

  • Dwarf Fortress v50.x (Steam / DF Premium) — tested with v50.14
  • DFHack v50.14-r1+ (Steam Workshop or dfhack.org)
  • Python 3.11+
  • An LLM provider (one of):
    • Ollama — free, runs locally, no API key needed (supports thinking models)
    • Anthropic Claude — API key required
    • OpenAI — API key required

Note: This tool uses DF Premium (Steam) APIs. Classic DF (pre-Steam) is not supported — some DFHack fields like unit.relations don't exist in the Steam version. We use histfig_links on historical figures instead.

Tech Stack

  • Backend: Python 3.11+, FastAPI, Pydantic v2
  • Frontend: Jinja2 templates, vanilla CSS/JS (no build step)
  • Game integration: DFHack Lua scripts
  • LLM: Anthropic SDK, OpenAI SDK, Ollama REST API (with thinking model support)
  • All narratives grounded in DF mechanics — the AI knows squad sizes, siege thresholds, temple values, what players can and cannot control

Documentation

See the Wiki for:

Notes

  • This tool is designed to run locally on your machine (localhost). It is not intended to be exposed to the internet or run on a public server.
  • Developed and tested on Windows with DF Premium (Steam). Should work on Mac and Linux — all code uses cross-platform libraries (pathlib, FastAPI) and DFHack APIs are platform-independent — but these platforms are untested. If you run into issues, please open a bug report.
  • Config and stories are stored at ~/.df-storyteller/. API keys are in config.toml.

License

MIT

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

df_storyteller-0.2.1.tar.gz (5.1 MB view details)

Uploaded Source

Built Distribution

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

df_storyteller-0.2.1-py3-none-any.whl (163.4 kB view details)

Uploaded Python 3

File details

Details for the file df_storyteller-0.2.1.tar.gz.

File metadata

  • Download URL: df_storyteller-0.2.1.tar.gz
  • Upload date:
  • Size: 5.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for df_storyteller-0.2.1.tar.gz
Algorithm Hash digest
SHA256 f6cc4ae533d6e515d24d14de7d0eaa60962f5f1d6fda3155dac44ef098e459ae
MD5 451e0782bf6d7260dfafdd501af05c25
BLAKE2b-256 07a0625bc8b6ca39db062d52e05c2621d3fce8fc485d0a47cf61cd5d10a30809

See more details on using hashes here.

File details

Details for the file df_storyteller-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: df_storyteller-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 163.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for df_storyteller-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 596c5d7be937d81ff8578c6a7cc6155d0d98104bc75eb2732f3603df502ca7bf
MD5 80efced18d98abc7a1565db5e43f8df9
BLAKE2b-256 c9b02dbf3dbe24f1c0b2305503799e1e59e3c4077d320d8bdeb8364a673caac0

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