Building AI Choose-Your-Own Adventures with Prompt Scaffolding

Create AI-driven choose-your-own-adventure experiences by grounding the model with a map, state-tracking, and short scene summaries to preserve continuity and guide branching.

If you talk to any developer who spends a lot of time doing AI and creative things, they probably all have a few favorite pet apps they like to build—some hobby project they keep coming back to, or some ongoing way to see what the model can do. I have a few.

One of them has been using models to generate comic book speech bubbles on images. I’ve actually built a pretty good pipeline for it. Not that I have any interest in making a comic book—it just seemed neat to try to figure out all the little pieces: identifying the face, deciding where the tail should point, sizing the bubble, and so on.

Another concept I return to a lot is choose your own adventure. Going back as far as GPT-2, people realized these models could be imaginative and hallucinate. That’s not ideal for factual work, but it’s great for certain kinds of storytelling. AI Dungeon was a popular app that used GPT-2 to create interactive stories.

It’s also interesting that computer-based choose-your-own-adventure style storytelling predates the Choose Your Own Adventure franchise. One of the earliest computer games was Colossal Cave Adventure, where you explored a cavern and looked for treasure. What made it especially fun was that the designers used a real cave system as the basis for the map, and then built a text simulator on top of it—adding goblins, treasure, and all the rest.

Some of my earliest prompts were basically: create a scenario, have the model generate the next scene plus a set of choices, then let the user pick a choice and continue. It quickly became obvious that the model tends to fall into familiar storytelling patterns—reusing the same types of arcs and even the same small pool of names these models seem to love.

I found it worked better to give it a bit more structure: simple randomizing functions (good outcome, bad outcome), a random name generator, and—most importantly—some kind of “source of truth,” like the map concept from Colossal Cave. When you give the model grounding, you end up with a much more interesting experience because the model does what it does best: fill in the gaps, rather than invent entirely new territories from scratch.

I’ve even taken some of the interactive stories I’ve made and put them into book form, which has been fun. I don’t really have plans to release them—there are plenty of choose your own adventure stories out there—but it’s been a great experiment, especially combining a couple of my interests (including image generation) to make endless choose-your-path style stories.

One technique I found useful back then—and it still works now—is to make sure the system is aware of the paths the user has taken, and ideally some of the alternatives they didn’t take. I’ve seen choose-your-own-adventure stories that just continuously generate new scenarios without much sense of what happened before, and it can get mind-numbing fast. It starts to feel like you’re stuck in some strange hallucination.

A simple fix is: after each scene and its choices, have the model also generate a short TL;DR of what just happened. Then you feed those summaries back in with the next prompt, so the model knows what the person did before—and you can even explicitly remind it, “they could have done X, but they chose Y.” If each scene is 500–600 words, a 40–50 word summary is usually enough to preserve continuity. You can also track state this way—like picking up an object in one scene and carrying it into the next. Without that, a lot of these stories end up circular or oddly flat, because nothing in the background is enforcing consistency.

Another thing I built was a system that generates all the paths ahead of time. Like Colossal Cave, it would create an entire map first, and then I could go back and decide what each branch meant: does this choice lead to more branching choices, or is it a dead end? That ended up being really helpful. If you’ve ever flipped to the back of a choose-your-own-adventure style book, you’ve probably seen maps that show which routes are a real adventure and which ones fizzle out. It’s a better pattern than pure randomness, because otherwise you often end up with a story that ends way too quickly.

If someone wants to try building one of these, I’d suggest starting with a path generator and ignoring the prose at first. Just figure out the structure: which choices branch, which choices terminate, and what a “winning path” even looks like. When I wanted to pre-write an entire choose-your-own-adventure style story, I’d create the map first, then write the winning path from start to finish, and only then go back and fill in all the branches.