AI Dungeon Master for D&D 5e

How It WorksCode runs the game. AI tells the story.

Every dice roll, HP calculation, spell slot, and combat turn is resolved by TypeScript before the AI sees it. The AI receives the outcome and writes the story around something it had no part in deciding.

This separation is the entire architecture. It determines what the game can do, what it costs, and why it works when other AI RPGs do not.

Read the dev log· Nine months of build logs· Every bug, every fix
The architecture

Why the separation
matters.

Most AI RPG products give the language model authority over game state. The AI rolls the dice, tracks the HP, manages inventory, decides whether your spell worked. Language models are bad at these jobs.

They lose track of numbers across turns, apply modifiers inconsistently, forget which NPCs are alive, and hallucinate outcomes that contradict what already happened. These failures are architectural. No prompt engineering, memory system, or model upgrade fixes them permanently because the problem is what the AI has been asked to do, not how well it does it.

In Chronicles of Terros, the AI is never asked to do those jobs. Code does them. The AI writes prose about resolved facts.

Architecture boundary
TypeScript (decides)
Dice rolls with real RNG
HP, AC, modifier arithmetic
Spell slot decrement + rejection
Combat state machine + initiative
Inventory, currency, equipment slots
NPC identity tokens
Character level, XP, class features
Crime detection + consequence timing
Read only
AI (narrates)
Scene description after skill checks
Combat narration from resolved outcomes
NPC dialogue + personality
Companion reactions + interjections
World atmosphere + sensory detail
Session orchestration + pacing
Story arc progression
Emotional tone + dramatic weight
The engine

What code handles.

Deterministic systems that must produce the same answer every time. No language model involved.

Combat

Combat runs as a state machine. Initiative is a sorted queue. Attacks resolve through code with real dice rolls, computed modifiers, and damage applied to code-owned HP fields. When a combatant reaches 0 HP, code removes them. The AI cannot keep a dead enemy alive or kill a player through narrative.

Spell casting

The spell’s level is checked against available slots, the slot is decremented, the attack roll or saving throw is computed per target, and damage or conditions are applied. All in code, before the AI generates a word. Cantrips scale by character level through a codified table. Upcasting consumes the correct higher slot. If no slot is available, code rejects the cast.

Equipment + inventory

Inventory, currency, and equipment are typed fields with separate mutation paths. Gold cannot overwrite experience points. Equipped items occupy specific body slots: head, chest, legs, feet, hands, cloak, neck, back, two ring slots, main hand, off hand, shield. Combat bonuses from magic items feed into the attack and AC math at combat start.

NPC identity

The AI writes placeholder tokens during generation, and a post-generation resolver replaces them with canonical names. The AI cannot rename an NPC because it never chooses the name.

Character progression

Level, XP, class features, and proficiency bonus are mutated only through the level-up code path. No AI output can write to these fields.

The narrative

What the AI handles.

Prose generation around outcomes it had no part in deciding.

The AI generates the text you read. It describes the scene after a skill check resolves, narrates the consequence of a combat turn the code already computed, and voices NPCs whose identities and states are managed by code.

Multiple AI systems run in parallel, each with a scoped job: one manages the story arc, one drives companion behaviour, one orchestrates the session. None of them touch game state. They coordinate through the code layer, which is the single source of truth for everything mechanical.

Companions

Fourteen handcrafted companions have independent relationship mechanics where trust, affection, and respect track separately. A companion can trust your judgment without liking you. They disagree with your choices, interject mid-scene, and take independent action when their values conflict with yours. The companion AI generates this behaviour. It does not decide whether the companion is present, alive, or mechanically effective. Code does.

Pricing

What this costs
and why.

£29
Once. No subscription required.

When code handles state, per-turn AI cost is bounded. The AI runs once for narrative, conditionally for companion reactions, and occasionally for classification tasks with tiny token budgets. No feature addition creates unbounded AI calls.

That bounded cost is why Chronicles of Terros is a one-time purchase, not a monthly subscription. The AI has a scoped job with a predictable cost ceiling. There is no credit system, no per-message charge, and no scenario where you pay to correct the game’s own errors.

Wanderer’s Pass · £6/mo
Voice narration for key scenes using a custom narrator voice built for the game. A Fate Thread system: one narrative rewind per story arc, triggered after you see the consequences. Carriage fast-travel with story encounters.
Chronicle Book · from £25
Your campaign printed and bound. Episode notes compress into arc chapters, which assemble into a full manuscript with a prologue, epilogue, and a “Choices That Mattered” section. Softcover, hardcover, or full-colour.
Further reading

From the blog.

The architecture behind the game, explained for people arriving from search.

Why AI Dungeon Masters Forget Everything

AI dungeon masters forget because they hold authority over game state. Bigger context windows and retrieval systems don't fix the root problem. Code-owned state does.

What an AI RPG Needs to Get D&D 5e Combat Right

Dice rolls, HP, AC, modifiers, and initiative belong in code. Here's what breaks when the language model does the arithmetic instead.

How to Play D&D Solo in 2026

A survey of current options — ChatGPT, AI Dungeon, dedicated AI RPG platforms, and solo toolkits — and where each one breaks.

I Built an AI Dungeon Master for D&D 5e. Here's What Breaks.

Nine months of building, one architectural decision, and every bug that revealed it was the right call.

Questions

FAQ

Can AI track D&D spell slots?

Only if code owns the spell-slot data. In Chronicles of Terros, casting a spell decrements the correct slot level in code before the AI generates narrative. If no slot is available, code rejects the cast. The AI cannot override a rejection or fabricate a slot.

Why does my AI dungeon master keep changing my stats?

Because the AI holds write access to your character data. When a language model can modify HP, level, or ability scores as part of generating text, it will sometimes overwrite values by accident. The fix is preventing AI from writing to those fields. In Chronicles of Terros, character stats are code-owned and AI-readonly.

Do AI RPGs need a subscription?

Most do, because when AI handles game logic, compute cost per turn is unpredictable. The model might need multiple attempts to resolve a combat action. When code handles logic and AI only generates narrative, cost per turn has a known ceiling, which makes one-time pricing viable.

How does voice narration work?

A custom narrator voice, built specifically for the game, reads scene descriptions, act transitions, and dramatic reveals. Companion banter, dice confirmations, and routine text stay text-only. Voice is part of the Wanderer’s Pass and is generated through Hume AI Octave TTS.

Can I print my campaign as a book?

The Chronicle Book system compiles your campaign into a formatted narrative. Episode notes compress into arc chapters, which assemble into a full manuscript with a prologue, epilogue, and a “Choices That Mattered” section showing what would have happened if you had chosen differently. Print-on-demand through Lulu.

Port Harmony
is waiting.

Five episodes free. No card required.