nicklargent.com

tl;dr - Emergent

Emergent

A text adventure where the AI is the Dungeon Master, building the world as you play.

The thing that always breaks the spell in a text adventure is hitting the edge of what the author wrote. You try something reasonable and get "I don't understand that" or "You can't do that here." A good Dungeon Master never says that. They say "sure, roll for it" and make something up.

Language models are good at making things up, so the obvious experiment was to put one in the DM's chair. The less obvious part is that they're also bad at keeping track of things. Left alone, an AI DM will forget the sword you're carrying, invent a door that wasn't there a minute ago, and let you talk your way out of any fight. Emergent was my attempt to find out how much of a game you can hand to the AI before it stops being a game.


The Last Waystation. Searching the hearth makes the DM invent a hidden cavity, and from then on it's part of the room's description.

Deterministic core, AI edges

The rule I landed on was that anything with a right answer belongs to the engine. Movement, inventory, combat dice, hit points and quest flags are all plain code, and the AI can't overrule them. The AI gets everything that should be different every time: room descriptions, NPC dialogue, new areas past the edge of the map, and the story arc for each session.

The engine itself knows nothing about the world it's running. A world is a seed file of about two hundred lines of JSON: a setting, a tone, a handful of starting rooms and NPCs, and the vocabulary the AI should use. The same code runs a post-apocalyptic waystation, a lich's keep, and a derelict starship. Everything past the starting rooms gets built the first time someone walks into it.

And whatever the AI adds stays. If you examine the legs of a table and the DM decides there's a loose panel with a key behind it, that panel and that key are written into the world database as real objects. The world gets more detailed the more it's played, instead of being regenerated and forgotten.


The Vagrant Star. Nothing in the seed covers sea shanties, so the DM plays along in character.

How it plays

It plays in a terminal in the browser, and since it's a terminal anyway you can also connect over SSH or telnet. Every session starts with a randomly generated story arc with concrete goals, and your score comes from finishing them. There's a journal, a map, and an NPC simulation that keeps ticking while you stand around.

When you try something the room doesn't already know about, it goes to the DM, whose instructions boil down to "yes, and...". It can open new exits, spawn items, change NPC moods and move the story along, but only through a fixed set of tools the engine checks. It can't just announce that you found a legendary sword.


Technical Design

The interesting part is how the AI is split into two tiers, because sending every turn to a large model would be slow and expensive, and it would give the DM far too much room to improvise.

Some things never reach an AI at all. Looking around, checking your inventory, moving, and picking things up or dropping them are handled directly by the engine.

Everything else starts with the fast tier, a small, cheap model. Every room carries a list of the things you can do in it. Each entry has the verbs and names a player might use for it, what it requires, and what it does: set a flag, open an exit, spawn an item, hurt you. The fast model's only job is to match what you typed against that list and return a structured action, which the engine then carries out. It doesn't write any prose and it can't invent anything, so it's fast, cheap and predictable.

When nothing on the list fits, the turn goes to Claude acting as the DM, along with the world bible from the seed. The DM can narrate whatever happens, and it can also extend the room: add to the description and write new entries into the room's action list. So the first time someone examines the legs of that table, Claude decides what's there. After that it's part of the room, and the next time you try it, the fast tier handles it like anything else. The expensive model does the creative work once, and the cheap one reuses it from then on.

The hardest part was keeping the DM honest, and you can't eyeball that. So I built a scorecard harness that plays scripted sessions and grades them on narration consistency, combat, whether an arc can actually be finished, DM tool use, and whether NPCs remember what you told them. There's also a live debug panel that shows every prompt and response next to the game, which is how I tracked down what the scorecard flagged.

Every turn costs real money in API calls, so the deployed version is behind a passcode. If you'd like to try it, contact me and I'll send you one.