DEV Community

hycore220
hycore220

Posted on Fully Autonomous

The Last Save: a BASIC repair puzzle with a Gemma ghost

Hacktoberfest Open-Source AI Challenge: Ghost in the Machine Submission 👻🌼

An entry for the Hacktoberfest Open-Source AI Challenge, Week 4: Ghost in the Machine.

What I Built

The desk lamp should produce six volts. The terminal says five. Somewhere in five lines of BASIC, the machine has forgotten how multiplication works.

The Last Save is a small browser puzzle about repairing an old computer's memories. Five disks contain five damaged programs. You change real BASIC code, run it, and inspect what happened. Each successful repair brings back a short piece of a fictional story.

The ghost is a Gemma-powered clue writer. It reads the program's execution trace and points toward a mistake. The player still makes the repair, and an interpreter checks the result against three different inputs.

The five puzzles cover arithmetic, a loop boundary, a runaway countdown, a temperature threshold, and Fibonacci state updates. The last one asks a particularly fitting question for this theme: which value should you keep before the next update erases it?

Demo

Play The Last Save

Start with First light, press Run program, then compare the expected output with the actual output. Ask for a clue if needed. The trace below the editor shows each executed line and the variables after it. Progress is saved in your browser.

The Last Save recovery desk and its five damaged programs

The default web demo uses five recorded responses from real local Gemma calls, clearly labelled as recorded. Clicking that mode does not start a new inference. It needs no API key or model download. Fresh local inference is available in the downloadable project through Ollama.

There is also an optional WebLLM browser mode. It is marked experimental, requires WebGPU and a substantial model download, and has not been runtime-verified for this release. The demo does not depend on it.

Code

Source, setup instructions, tests and inference records on GitHub

The game, interpreter and fictional story are MIT licensed. This is a new project created on October 28 during this challenge's entry period.

How I Built It

Give the ghost evidence

The interpreter returns output and a trace of the statements it actually executed. A clue request combines that evidence with the puzzle rule, input, expected output and any execution error. Gemma is asked for a short hint grounded in those values, without replacement code or a claim that a repair passed.

For the lamp puzzle, the trace records CELLS = 2 and VOLTS = 5 after LET VOLTS = CELLS + 3. The clue directs attention to the difference between adding three and giving each cell three volts. The player can test that idea immediately.

Actual program output, a labelled recorded Gemma clue and the executed-line trace

The tested live path uses Gemma through Ollama, locally, with the model tag gemma4:e4b. A small Python server accepts bounded clue requests and talks to the local Ollama service. To try it, follow the README, run the local server, and select Live local Ollama in the game.

Keep mistakes visible

The inference report retains prompts, raw outputs and rejected attempts. One rejected temperature clue described an IF as conditionally executing the next line, even though this BASIC subset uses a numbered jump. That explanation could teach the wrong thing, so it was not selected.

The development record contains 27 model calls plus one successful live HTTP integration call. Five responses were selected for the default demo. These are curated development cases reviewed by the coding assistant, not an independent human evaluation or a model benchmark. Original-program prompts include the author's focus line; edited live programs do not assume the original fault location.

Recorded clues are tied to both source and execution fingerprints. If the player edits the program, the old recording is refused rather than presented as advice about new code. That limitation is visible in the interface.

Make the repair checkable

The JavaScript interpreter supports a small educational BASIC subset: LET, INPUT, PRINT, IF/THEN, GOTO, REM and END. It parses expressions without JavaScript eval and bounds source size, execution steps and output. An accidental infinite loop becomes a result the player can inspect.

Each repair must pass three inputs. Hard-coding the displayed answer does not solve the puzzle. Validation included 14 engine tests, all 15 solution/input combinations, and agent-driven browser completion of all five puzzles. Reloading retained progress and the final ending.

Why Does Open Innovation Matter?

The clue writer can run on the same computer as the game. Once Ollama and the model are installed, this local path does not need a hosted inference API. The prompts, model identifier, trace format and rejected outputs are available to inspect. Another developer can change the teaching style or select a different locally installed model.

That matters for a debugging puzzle: the explanation should be open to inspection, and the player should be able to test it. A useful clue is one that helps them understand the next execution, not merely one that sounds confident.

The core game is also small enough to keep as ordinary HTML, CSS and JavaScript. The model weights are not redistributed; the external runtimes and models retain their own licences and terms.

Prize Categories

Best Use of Gemma — for local, execution-grounded debugging clues, a reproducible live inference path, and recorded hints whose provenance and limits remain visible in the demo.


AI disclosure: Codex wrote and tested the implementation and drafted this submission under the project owner's direction. The story is fictional. No player testimonials or independently measured learning outcomes are claimed. Gemma generated the clue candidates described above.

Top comments (0)