Hop tu Naa Simulator:以 Gemma 打造曼島「不給糖就搗蛋」遊戲
Hop tu Naa Simulator
Hop tu Naa Simulator 是一款以曼島為背景的 2D「不給糖就搗蛋」遊戲,使用 Ollama 本機運行的 Gemma 即時創作居民角色、對白和笑話。玩家可在 21 間房屋前選擇説「不給糖就搗蛋」、唱 Hop tu Naa 歌曲或講笑話;ElevenLabs 語音功能則為居民和玩家提供語音。Gemma 負責創作,遊戲規則由程式碼控制;即使沒有 ElevenLabs,遊戲仍可運作。
This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine
What I Built
Hop tu Naa Simulator is a 2D trick-or-treating game set on the Isle of Man. You wander a hand-drawn map of the island, from Ramsey and Laxey to Douglas, Peel, Castletown and Port Erin, and knock on doors. Each house is answered by a different elderly resident, invented on the spot by a local AI model, who speaks to you out loud.
At every door you get three choices: say "Trick or treat!", sing the Hop tu Naa song, or tell a joke. Some residents hand over treats for a simple "trick or treat". Others insist on the song ("Hop-tu-Naa, my mother's gone away, and she won't be back until the morning"), and they drop hints in their greeting. Jokes are generated fresh each time and never win a treat, but they get a great reaction.
My take on "Ghost in the Machine": the residents are small ghosts living inside a model. They're each a bit of Manx folklore (Jinny the Witch, the Moddey Dhoo, turnip lanterns, kippers, the TT) that talks back. Hop-tu-Naa is the Manx Celtic festival celebrated on 31 October, with carved turnips rather than pumpkins, and I wanted to keep that tradition alive in a form people can play with. Voices make it feel like a real doorstep, not a text box.
Demo
Code
Check out the folder 4 here:
How I Built It
Using Claude within Copilot, we brought this app to life using Gemma and ElevenLabs to create a magically spookful experience!
- Open model: Gemma via Ollama, fully local. Gemma invents each resident (name, age, look, treat, greeting) as JSON, writes each reply in character, and generates the jokes. Nothing about the dialogue leaves the machine.
- Game rules stay in code. The app decides whether you succeed, depending on whether the resident wanted a "trick or treat" or the song. Gemma only writes how they react. That keeps the game fair and stops the model from handing out treats unpredictably.
- Tiny Node server, no dependencies. It serves the page and proxies requests to Ollama. It also proxies ElevenLabs, so the API key never reaches the browser.
- Map: a hand-plotted SVG outline of the island with 21 clickable houses.
- Speed work: residents are pre-generated in the background in random order, and a house's porch light only comes on once its resident is ready. I also capped tokens, turned off Gemma's thinking, kept the model loaded, and added retries and a repeat penalty after hitting loop errors.
ElevenLabs: giving the ghosts voices (Best use of ElevenLabs)
ElevenLabs text-to-speech is what makes the doorstep feel real:
- Every resident has a voice. The app picks a gender for each resident, which Gemma taps into. The app maps them to one of several ElevenLabs voices (older-sounding ones first), chosen by hashing the resident's name so the same person always sounds the same. The server fetches the voices your account can use and selects from them.
- Residents speak both their greeting and their reaction to what you said or sang.
- The player has their own higher, lighter voice. ElevenLabs has no pitch control, so I play it back slightly faster with pitch preservation off to simulate a child's voice.
- Manx pronunciation fixes. The app rewrites spoken text so "Hop-tu-Naa" becomes "Hop chew nay" and "Moddey Dhoo" becomes "Mor-ver doo". The on-screen text stays correct. Without this, a general-purpose voice mangles the cultured words that matter most.
-
Fast, resilient audio. I use the low-latency
eleven_flash_v2_5model. If there's no key, or a voice isn't allowed on the plan, the game carries on silently, and there's a Voices on/off toggle.
Why Does Open Innovation Matter?
Running Gemma locally through Ollama meant I could generate unlimited characters, jokes and retries with no per-token cost, no rate limits and no data leaving my machine. That freedom is what let me pre-generate a whole island of residents and retry failures aggressively. I also had direct control of the model settings (token caps, thinking off, repeat penalty, keep-alive). With a closed API, that kind of experimenting would cost money on every attempt.
To be honest about the stack: Gemma is the open part. ElevenLabs is a hosted service, so I treated it as an optional layer. The game fully works without it, and the open model does the creative work.
The Spirit of It
As a Manxman, building an app to celebrate Hop tu Naa and its traditions – turnips, Jinny the Witch, and the Moddey Dhoo – felt apt for this challenge. Using open AI ahead of the Isle of Man's first Hack Day on the 31st felt even more perfect. This app will make a great demonstration that can be used at the Hack Day to show to the island's youth just what you can build using open-weight AI.
Prize Categories
- Best Use of ElevenLabs
- Best Use of Gemma
- Best Use of GitHub Copilot
來源:DEV Community · dev.to


