Building a branching narrative without branches: how our AI story engine works

Classic interactive fiction — Choose Your Own Adventure books, text quests, visual novels — all share the same structural problem: somebody has to write every branch. The content cost grows exponentially with player freedom, so in practice "choices" converge back to a handful of scripted endings.

When we started Interactive Stories (Интерактивные истории), we deleted the branches entirely. There is no story tree. There is a world state, a cast of characters, and an LLM that writes the next scene in response to whatever the player did — including actions nobody ever anticipated.

The architecture in brief

The player picks a story (mystery, fantasy, detective, survival) and gets an opening scene plus 2-3 suggested actions. But there's always a fourth option: type anything. "Burn the house down". "Call my mom". "Challenge the ghost to a dance-off". The model accepts it and continues the story with the consequences.

Technically:

  • Streaming generation. The response streams to the phone over SSE, so text appears progressively like a messenger typing indicator. Perceived latency matters more than total latency — if the first words appear within ~2 seconds, the magic survives.
  • Server-side state. Story progress lives server-side. Reinstalling the app doesn't lose your run — and (importantly) it lets us meter usage honestly.
  • Metered usage. The first 12 generations in each story are free; after that the story is a one-time cheap unlock. Usage is counted server-side per generation — an early prototype trusted the client's count, which is exactly as exploitable as it sounds. Don't do that.

What playtesters actually do

The first thing every player does is try to break the game. That's not a bug — it IS the game. When someone types "I pull out an accordion and start playing" and the plot accommodates them, they're hooked. The AI's ability to take absurd input seriously is the core delight.

The second thing they do: get emotionally invested in ways scripted fiction doesn't achieve, because the protagonist's decisions were genuinely theirs. Players blame themselves for bad endings. That's a compliment.

Lessons

  1. Free input beats suggested actions. The suggestions exist mostly to teach new players that input exists at all. Veterans mostly type.
  2. Latency is everything. Stream, don't batch.
  3. Never trust the client for anything that costs you money — metering, pricing, content parameters all belong server-side.

The app is live on RuStore (Russian Android store): https://www.rustore.ru/catalog/app/com.SpeedOfLightGames.AIbook

Happy to answer questions about the narrative state management in the comments.