← All experiments

A clinic-⁠shift game for board-⁠exam practice, built by an autonomous agent loop

I wanted a board-exam practice game for my new handheld, and I wanted to see how long an AI build could run on its own. Over two days an autonomous Claude loop, checked by Codex at every milestone, built a pixel-art clinic where every patient is a question.

  • Games
  • Education
  • Health
  • Automation

Updated14 Oct 2026

The problem

I wanted a game for board-exam practice in pediatrics, internal medicine and Med-Peds that would run on the Retroid Pocket 5 handheld I had just ordered. I also wanted to test an AI build that works on its own for as many hours as possible, checks every step before moving on, and wakes itself up again after hitting the 5-hour usage limit.

What was out there

The project notes do not compare existing quiz games. The gap I hit was in the tooling: a Claude Code session stops at its usage limit and does not restart by itself, so a long unattended build needed its own wake-up layers.

What I built

Primary Doctor is a Godot game. The player is a resident running a morning clinic shift from 08:00 to 12:00, with 6 scheduled and 4 urgent patients. The nurse calls the doctor, the doctor walks between rooms with a D-pad or stick, and each visit is a board-style question with shuffled options. Wrong answers bring the patient back, an attending gives feedback, and weak topics come back more often in later shifts. There is a title screen, a pause menu, an end-of-shift report and 16 pixel portraits.

The questions come from a separate bank of 1,200 draft items that are still waiting for review by certified doctors. I use them only on my own machines, behind a "Draft, not clinically reviewed" banner, and nothing is published.

Top-down pixel-art clinic: four exam rooms along the top, a corridor, a waiting room, the nurse's desk and two pink urgent bays. A bar across the top shows the clock at 09:30, an urgent alert, the score and patients seen.
The clinic in the middle of a test shift. The yellow and red markers are waiting patients, and the top bar holds the clock, alerts and score.
Title screen reading Primary Doctor, a primary care clinic shift for board-exam practice, with a yellow line saying the 1,200 draft questions are not clinically reviewed, and buttons for the pediatrics, adult and Med-Peds clinics and How to play.
On the title screen you pick the clinic, and a line says up front that every question is a draft doctors have not yet reviewed.
End of shift panel with feedback from the fictional attending, counts of patients seen, correct decisions, patients who left or were transferred, the score, and the weakest topic so far, with Next shift and Title buttons.
The end-of-shift report from a scripted test run. The attending's feedback and the weakest topic carry into the next shift.

Equipment

How I built it

  1. I approved a written plan and mandate: twelve milestones (M0 to M11), tests written before code, decision tiers for what the loop may decide alone, and a list of things that always need my go (publishing, spending, messages).
  2. Each milestone ran the same loop: plan, build, test, review. At the review gate a Claude verifier and a code reviewer checked the work, and Codex (GPT-6 Astra) did an independent read-only review. A milestone got at most three fix rounds, then one Codex rescue in its own git worktree.
  3. Three wake layers kept it going: an hourly in-session timer, a scheduled watchdog every two hours that acted only if the heartbeat was more than 90 minutes old, and keep-awake on the Mac.
  4. In every full check, scripted bots (idle, greedy, guessing, competent, human-like and perfect) played 500 seeded shifts to test the rules, the balance and the adaptive question picker.
  5. The exports came last: a debug APK verified in an Android 13 emulator at the handheld's resolution, and a web build played in the browser.

Results

  • All twelve milestones, M0 to M11, passed their gates. The first commit landed at 02:25 on 13 October 2026, the merged prototype at 23:12 the same day, and the follow-up fixes on 14 October: 95 commits in all.
  • The final whole-game review passed with 8 out of 10 from each of the visual critic, the Claude reviewer and Codex.
  • The full check runs 120 unit tests and 84 flow checks, answers every one of the 1,200 questions through controller input, and simulates 500 shifts. It takes about 45 minutes.
  • Over five campaigns of 60 shifts, the adaptive picker gave weak topics 45.5% of the questions, against 20.6% for a control without adaptation. Missed questions came back the next shift 11.7% of the time, against 1.5%.
  • A full shift ran at a mean frame time of 3.31 ms on the Mac, against a gate of 8 ms.
  • 318 of the 1,200 questions were labelled urgent, with agreement kappa 0.94 between the two AI raters.
  • The loop found a problem in the question bank itself: option A is the correct answer in 1,113 of 1,200 questions (93%), and the correct option is the longest one in 841 (70%). The game shuffles the options; the length cue is for the reviewing doctors.
  • I played it on the Mac on 14 October 2026: "This is such a fun game!" The checks on the handheld itself were still pending in the project notes.

What I learned

Simple bots test content as well as code. Running scripted players over the shift rules is what surfaced the answer-key bias in the question bank, which nobody had been looking for.

A passing test proves little if it could never fail. The reviewers kept finding tests like that: a weighting test that passed on the buggy formula, an adaptivity gate that held on only one random seed, checks that ran on an empty waiting room. From then on every fix came with a test that was shown to fail when the old bug was put back.

Check what a measurement is measuring. Frame times of 8.35 ms looked like a performance problem until I noticed that 1/120 of a second is 8.33 ms: the Mac's 120 Hz screen was pacing the frames. With vsync off it measured 2.80 ms.

Lab notes

  1. The seven minor findings from the final review were fixed, each with a test that fails if the old bug comes back.

  2. When the art pass stalled at 6 out of 10 against the concept, I escalated it to Codex, and two fresh reviewers scored the rescue 7 out of 10. The loop built a debug Android APK and a web build, and I merged the prototype once the final whole-game review gave 8 out of 10 from the visual critic, the Claude reviewer and Codex.

  3. Two independent AI raters labelled all 1,200 questions as urgent or scheduled, with an adjudicator for the 29 disagreements. They agreed at kappa 0.94; the old keyword rule had reached only 0.35.

  4. I started the autopilot with a written mandate, a test harness, timers to wake the run after usage limits, and two Codex concept images that set the art direction. The run paused twice at the usage limit and resumed from the saved state each time.

© 2026 Johnattan García-Ruiz Last updated