This is a submission for the Gemma 4 Challenge: Build with Gemma 4
What I Built
GemMaster is a specialized narrative engine designed to move beyond the traditional "chat window" paradigm. It transforms the classic text-adventure into a cinematic experience, bridging the digital and physical worlds through multimodal AI visionβall while running 100% locally on your machine via Ollama.
π The Vision: Testing the "Brain" of Local Models
I wanted to see what a local model really has in its belly (or its head!): could it handle being a rigid Game Logic Orchestrator while maintaining a cinematic soul? GemMaster proves that with rigorous "Engine-level" prompting and a clever frontend, a tiny model like Gemma 4-E4B can deliver a surprisingly deep and interactive experience directly on consumer hardware, with total privacy.
β οΈ IMPORTANT
Performance Note: I've optimized this engine specifically for Gemma 4 E4B and larger. Due to the high complexity of the multi-tag protocol, the E2B model may experience "formatting drift" in long sessions.
ποΈ Video Game Architecture: The Anatomy of a Turn
Unlike standard LLM chats, GemMaster treats every response as a Game Frame.
- The Wizardβs Spark: Choices (Universe, Tone, Language) are converted into a dynamic JSON configuration injected into the base prompt.
- Linguistic Sovereignty: Dynamic system reminders prevent "Language Drift," keeping narrations and tags perfectly aligned with the user's locale.
- Continuity: A Session-Lock System and Markdown-based journal ensure long-term narrative consistency.
Demo
GemMaster features a Liquid Glass Design with hardware-accelerated CSS filters and dynamic "Ambilight" backgrounds that shift based on the story tone (Action = Red, Tension = Purple, Mystery = Blue).
ποΈ Multimodal Immersion (Experimental)
-
ποΈ Voice of the Director: Using the Web Speech API to read the AI's internal intentions through the
<voiceover>tag. - πΈ Visual Portal: A high-tech laser-scanning interface for image analysis challenges, bridging the gap between the physical world and the narrative.
Code
You can explore the source code and run the engine yourself here:
π GemMaster on GitHub
git clone https://github.com/QuentinMerle/gemmaster.git
cd gemmaster
./install.sh
python main.py
How I Used Gemma 4
I chose Gemma 4-E4B for its perfect balance between reasoning capabilities and local performance.
π οΈ Taming a 4B Model: The "Mechanical Toolkit"
I gave Gemma a full toolbox of interactive skills. The model doesn't just write; it triggers specialized components:
- π² [[CHECK: Stat|DC]]: Triggers a deterministic 3D dice roll.
- β‘ [[SKILL: QTE]]: Triggers a physical Quick Time Event.
- ποΈ [[SKILL: VISION]]: Triggers real-world image analysis.
π¨ Creative Constraints: Freedom through Structure
By enforcing tags for mechanics, I free the model's "brain" from worrying about how to resolve actions. It just triggers the tag, and then focuses 100% of its attention on the quality of the prose.
π Behind the Glass: The "Cheat" of Immersion
- The "Silent Shepherd": Hidden rule reminders appended to every user message to prevent "Model Drift."
- The Atomic Parser: A custom regex engine extracting tags from the stream in real-time.
- Deterministic Resolution: Offloading game logic to the frontend using seeded randomness to ensure "fair" play.
Conclusion
π GemMaster proves that small local models like Gemma 4 are capable of high-fidelity, multimodal orchestration. Iβve tried to build more than just a game; I hope it serves as a modest exploration of what is now possible in the local AI era.
π A Final Note
While Iβve spent far more time on this than originally planned, this is still an experimental engine. There may be some bugs or narrative "glitches" along the wayβI appreciate your indulgence, and most of all, I hope you enjoy the adventure!





Top comments (0)