{"slug": "your-story-local-gemma-4-interactive-fiction-that-remembers-your-choices", "title": "Your Story: Local Gemma 4 Interactive Fiction That Remembers Your Choices", "summary": "\"Your Story,\" a Flutter mobile app that uses local Gemma 4 AI models to power interactive fiction. Unlike traditional choose-your-own-adventure games, the app allows players to type natural language actions, which the AI evaluates and responds to while a deterministic state engine records permanent consequences. The goal is to create a playable novel experience that combines creative AI storytelling with consistent, state-driven world logic, as demonstrated in a sample \"Jack and the Beanstalk\" story.", "body_md": "This is a submission for the Gemma 4 Challenge: Build with Gemma 4\nYour Story is a Flutter mobile app for interactive fiction powered by local Gemma 4 models.\nThe 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.\nThe goal is to make AI storytelling feel less like a loose chatbot and more like a playable novel:\nThe 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.\nVideo walkthrough: https://github.com/tuandinh0801/your-story/blob/main/docs/assets/your-story-mobile-demo.mp4\nPlanned walkthrough:\nRepository: https://github.com/tuandinh0801/your-story/tree/main\nGemma 4 powers the core storytelling loop. It is not just used for a side feature.\nI use two local Gemma 4 LiteRT-LM models through flutter_gemma\n:\nThe app also has a Firebase AI cloud route for fallback and enhanced tasks. Each agent request declares a routing policy:\nThe router records which backend and model served each request. That makes the multi-agent system visible for debugging while keeping the reader experience simple.\nInteractive 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.\nYour Story splits the job:\nThis lets Gemma 4 do the creative language work while the app keeps the world consistent.\nThe 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.\nFor 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.\nflutter_gemma\n.", "url": "https://wpnews.pro/news/your-story-local-gemma-4-interactive-fiction-that-remembers-your-choices", "canonical_source": "https://dev.to/1412601/your-story-local-gemma-4-interactive-fiction-that-remembers-your-choices-43d5", "published_at": "2026-05-20 04:11:33+00:00", "updated_at": "2026-05-20 04:33:21.918660+00:00", "lang": "en", "topics": ["artificial-intelligence", "large-language-models", "open-source", "developer-tools", "products"], "entities": ["Gemma 4", "Flutter", "Firebase AI", "Gemma 4 LiteRT-LM", "Jack and the Beanstalk", "Your Story", "GitHub", "Google"], "alternates": {"html": "https://wpnews.pro/news/your-story-local-gemma-4-interactive-fiction-that-remembers-your-choices", "markdown": "https://wpnews.pro/news/your-story-local-gemma-4-interactive-fiction-that-remembers-your-choices.md", "text": "https://wpnews.pro/news/your-story-local-gemma-4-interactive-fiction-that-remembers-your-choices.txt", "jsonld": "https://wpnews.pro/news/your-story-local-gemma-4-interactive-fiction-that-remembers-your-choices.jsonld"}}