Skip to content
All builds

GloamAI Narrative Game

What it does for you

A text dungeon where the world is authoritative code and Claude only narrates, with a validator that drops any sentence naming things that are not there.

Gloam screenshot

Screenshots

Gloam screenshot 1

In more detail

Gloam is a text dungeon adventure where the game world is real code and the AI is only allowed to describe it. AI story games tend to drift: the model forgets what you carry, invents doors, and hands out items that do not exist. Here the world is the authority, the model narrates on a short leash, and the whole game still works with no API key at all.

Honest limits

The live Claude narrator is built but tested only against fake responses. It has not run with a real key. The validator does not understand room names or synonyms, so it drops more harmless sentences than it needs to. The UI was driven through the Chrome DevTools protocol (typing, history, autocomplete, saves, replay, settings, zero console errors), not by hand.

How I built it

I set the rule that the world is code and the AI only narrates, and I chose the scope: a dungeon map, NPC memory, quests, and a validator. Claude Code wrote the rest in one session. There is a seeded dungeon generator with guaranteed connections and a locked iron door at the exit, a parser with "did you mean", and a pure rules engine where every command becomes a new state plus a list of events. Three NPCs have moods and memories, three quests have multi-step flags, and a turn clock runs combat, lantern oil, darkness, and a wandering goblin.

Claude Code also wrote a scripted player, a small solver that reads the state and picks the next command. It doubles as the test that seeds are winnable (it wins at least 24 of 25 seeds on easy and normal) and as a full playthrough to victory that then replays identically. It also wrote hostile fake model replies (invented torches, a north exit that does not exist, raw JSON), and the validator drops each one.

What I learned

  • Keeping the dice inside the state is the whole trick. The random generator is one number stored in the game state, and step(state, input) is pure. A save is a snapshot, a log is a script, and determinism is testable with a plain deep-equal. Claude mode returns byte-for-byte the same state as local mode, and a test proves it.
  • The validator got simple once the prompt sent only this turn's events and a short summary. The allow-list is just inventory, visible items, this turn's events, real exits, and NPCs present. Dialogue needed one extra rule: an NPC may name what it holds, so Maren can mention her own key.
  • Strict validation drops some innocent sentences, and that is the right trade. A lost line of flavor costs little. An invented exit costs trust.
  • Headless Chrome will not lay out narrower than about 500px, so a 390px screenshot showed overflow that was not there. Real mobile checks needed device emulation.

What carried forward

It was built under the small-writes rule from the September 20 stall: 20 core modules, 10 test files, and 7 UI modules, with bigger files grown in chunks. Nothing was lost this time, and the module graph came out cleaner. The headless Chrome lessons started back in #7 with absolute Windows paths; this build added the 500px floor. The replay-from-a-log idea matches #82, and seeds as the source of truth match #89.

If I took it further

I would stream Claude's prose and validate it sentence by sentence as it arrives, and teach the validator room names and simple synonyms.

#090 Built with Claude Code September 23, 2026 346 automated checks

Want one like this?