DEV Community

Mohammad Hammad Ahmad
Mohammad Hammad Ahmad

Posted on

AI is the entire game engine

Most developers use AI to help write their app.

I made
 . 🎲

AI Dungeon Master is a Flutter RPG with zero scripted story. Every scene, enemy, NPC, loot drop and plot twist is generated live by an LLM (Llama 3.3 70B on Groq) and streamed into the UI token by token.

The fun part isn't the chat. It's treating the model like a game server:
→ Every turn must return strict JSON — narration, scene type, HP/XP/gold deltas, loot, who's on screen
→ The app parses that JSON while it's STILL streaming, so the story types out live
→ Client-side rules enforce fairness when the model misbehaves — damage fallbacks, HP/XP clamps, a 5-turn death grace, level-ups, potion logic

The lesson I keep coming back to: LLMs aren't just chatbots. With structured output + client guardrails, they can drive real, stateful app logic.

I open-sourced it 👇 Curious what other people are using structured LLM output for — what's the weirdest thing you've made a model return JSON for?

Flutter #LLM #GenerativeAI #MobileDev

Top comments (1)

Collapse
 
mhammadapp profile image
Mohammad Hammad Ahmad

🔗 Repo's open source here:
github.com/HammadAhmad200/ai_dunge...

Built in Flutter — Llama 3.3 70B on Groq for the generation.