Session

An AI Dungeon Master: The Worker Rolls the Dice, the AI Tells the Story

Ask an LLM to run a combat encounter, and it will cheerfully let your level-1 fighter one-shot a dragon, because it has no concept of dice, hit points, or fairness. It's a language model, not a rules engine.

AI Dungeon is built around the opposite premise: the Worker is the source of truth for rules, the AI is the source of truth for prose. Every mechanical decision (attack rolls, damage, XP thresholds, loot tables) happens in deterministic server code. The AI only ever narrates results it's handed, never invents them. That single architectural choice is what separates "an LLM wrapper" from a working game, and it's the thread that runs through every phase of this workshop.

Over four hours, in ten short phases, you'll build:

* The data layer: a Cloudflare D1 schema for characters, inventory, monsters, and quests
* The rules engine: a server-side dice roller, ability scores, and character creation
* The AI Dungeon Master: structured prompt engineering, a primary/fallback model strategy, and defensive JSON parsing that survives a model behaving badly
* The Angular frontend: signal-based state, a game console, and a dark-fantasy UI
* Combat and progression: turn-based encounters and D&D 5e-style leveling
* The economy: shops, inventory, and a paginated adventure log
* A real deployment: including the ten production issues we actually hit shipping this exact app, from CORS wildcard matching to a mid-project model deprecation

Each phase ships as a starter/ (TODO-stubbed files to fill in) and a solution/ (the finished code), so you can work at your own pace and always have a working checkpoint to fall back to. By the end, you'll have a deployed, playable game — and a template for building any application where an LLM needs to collaborate with code it can't be trusted to replace.


Format: Hands-on workshop
Duration: 4 hours
Level: Intermediate (comfortable with TypeScript; no Cloudflare or LLM experience required)
Stack: Angular 18, Cloudflare Workers (Hono), D1, Workers KV, Workers AI

Bob Fornal

Microsoft MVP | Senior Developer with a passion for learning, testing, mentoring, speaking and personal growth. Blessed husband and proud father of two.

Grove City, Ohio, United States

Actions

Please note that Sessionize is not responsible for the accuracy or validity of the data provided by speakers. If you suspect this profile to be fake or spam, please let us know.

Jump to top