# Your Story: Local Gemma 4 Interactive Fiction That Remembers Your Choices

> Source: <https://dev.to/1412601/your-story-local-gemma-4-interactive-fiction-that-remembers-your-choices-43d5>
> Published: 2026-05-20 04:11:33+00:00

This is a submission for the Gemma 4 Challenge: Build with Gemma 4
Your Story is a Flutter mobile app for interactive fiction powered by local Gemma 4 models.
The app starts from structured story templates, then lets players act in natural language. Instead of branching only through fixed choices, the player can type actions like "I hide the beans and tell Mother the truth" or "I ask the giant's wife for help." The story engine evaluates what is possible, Gemma 4 writes the next passage, and deterministic state logic records permanent consequences.
The goal is to make AI storytelling feel less like a loose chatbot and more like a playable novel:
The first story is Jack and the Beanstalk, with 13 beats, 6 characters, 7 locations, and a state model for choices such as trading the cow, taking treasure, earning trust, or angering the giant.
Video walkthrough: https://github.com/tuandinh0801/your-story/blob/main/docs/assets/your-story-mobile-demo.mp4
Planned walkthrough:
Repository: https://github.com/tuandinh0801/your-story/tree/main
Gemma 4 powers the core storytelling loop. It is not just used for a side feature.
I use two local Gemma 4 LiteRT-LM models through flutter_gemma
:
The app also has a Firebase AI cloud route for fallback and enhanced tasks. Each agent request declares a routing policy:
The router records which backend and model served each request. That makes the multi-agent system visible for debugging while keeping the reader experience simple.
Interactive fiction needs low-latency language generation, but it also needs long-running coherence. A pure cloud chatbot can produce prose, but it can drift from prior choices. A fixed branching engine can preserve state, but it limits the player's imagination.
Your Story splits the job:
This lets Gemma 4 do the creative language work while the app keeps the world consistent.
The app treats a story like a living state machine, not a chat transcript. The AI receives story rules and state context, then the engine validates what changed. Choices become durable facts that later turns can reference.
For example, if Jack trades Daisy for beans, that inventory change and relationship impact are stored as state. Later narration can reflect Mother's disappointment or trust because those values are no longer just text in an earlier paragraph.
flutter_gemma
.
