What if NPCs in games could actually hold smart, context-aware conversations — without ever touching the cloud?
That’s what I set out to build for the Google Gemma 3n Hackathon: a privacy-first, offline-ready AI NPC system, powered by Gemma 3n running locally via Ollama.
The result? A 2D Godot game where NPCs teach sustainable farming and botany using natural language — and it’s all open source.
🎯 The Goal
Create an educational game with AI-driven characters that:
- Run entirely offline using a local LLM
- Provide immersive, Socratic-style learning
- Are modular, configurable, and open source
This is not just a chatbot skin — it’s a framework for teaching real-world skills in a way that's private, interactive, and offline-first.
🔧 Tech Stack
- Godot 4.x with C#
- Gemma 3n running locally via Ollama
-
Custom NPC component that supports:
- Structured system prompts
- Configurable local model endpoint (localhost or LAN)
- Local inference (no API keys or cloud services)
💡 The NPCs feel alive because each one has its own backstory and mission, set via prompt engineering. You decide how they speak, what they know, and how they teach.
⚙️ How the System Works
Each NPC node includes:
- 🧠 A System Prompt (defines behavior and knowledge)
- 🔌 A Model Endpoint (Ollama on device or LAN)
- 🎮 A Trigger for starting conversations
When the player interacts, the system:
- Sends the prompt to the Ollama server with context
- Waits for a local Gemma 3n model to respond
- Displays the dialogue in-game, with typing and animation
- Tracks learning checkpoints (e.g. completed botany lessons)
No cloud. No scripts. Just smart conversations happening locally.
📹 Quick Demo
🎥 Watch the 2-minute presentation video:
👉 https://www.youtube.com/watch?v=kGyafSgyRWA
It shows a complete conversation with an NPC who guides the player through basic plant care and composting techniques — all powered by local AI.
🔓 Open Source
This project is fully open source and designed for reuse:
- GitHub: https://github.com/code-forge-temple/local-llm-npc
- License: CC BY 4.0
- Includes install docs, screenshots, and configuration tips
You can fork it, build on top of it, or just borrow the local AI NPC component for your own projects.
🚀 What’s Next?
After the hackathon ends, I plan to:
- Add biome-specific knowledge modules (desert, rainforest, etc.)
- Explore knowledge graphs for fact-checking
- Improve modularity so NPCs can be plugged into other games easily
- Add optional voice support and multimodal interaction
I also want to explore using this in other domains like:
- 📚 Offline learning for rural schools
- 🧠 Mental health support bots
- ♿ Accessibility tools for low-connectivity regions
💬 I’d love your feedback!
- Could you see this used in your own game or learning tool?
- How would you improve the system’s modularity or UX?
- Got ideas for extending it beyond farming and botany?
Let’s make games — and tools — where AI isn’t just smart, but private, resilient, and truly yours.
Thanks for reading! 🌱
Feel free to reach out or drop a star on GitHub if you’d like to support this type of open, local AI development.
Top comments (0)