The problem
In online games, turns sometimes skipped or a player got two in a row. It looked like a network
fault, and the obvious fix was a different way of connecting players, peer to peer instead of
through a relay.
What I found
- It was a question of who owns the turn, not of the network. Each player's game was
allowed to move the turn on by itself, and some fallbacks let two games both believe it was
their turn. Changing how players connect would not have fixed that.
- The fix: one game decides. The host's game now replays every move and is the only one
that advances the turn; the others apply what it sends.
- A second bug hid inside the first. The host was swallowing its own turn messages while
it replayed another player's move, so players drifted out of step on some cards. Found, fixed
and covered by a test.
- A third: bots in mixed games. With two people and a bot, the host could not drive the
bot's turn, so the bot was skipped. Fixed with a single clear rule for who may act.
- Bots that respect difficulty. The difficulty setting used to be stored and never read,
so every level played the same. Now easy bots cut a rival only as a last resort, normal bots
when it pays, and hard bots hunt the human players. 27 checks pin that behavior.
How I worked with the AI
I set the rules of the game and the standards for the code; the AI wrote and tested it. The rules
that mattered: reproduce a bug in a test before fixing it, never call something done until it has
been run, and say plainly what was and was not checked. When I found a problem by playing, it
became a test so it could not come back.
The proof
- A headless test that plays two games at once, host and guest, over a simulated relay. It
reproduced the turn drift before the fix and passes after it.
- 44 test files across the rules engine, turn rotation, the card 7 split, card 4 moving
backward, the deck and the bots.
- The public version is checked in a real browser on every publish: four players take turns
round the table, nothing is missing, and nothing loads from any other site.
- A deploy bug, caught and fixed: the publish script skipped every folder named "engine",
which included the game's own rules, so the board went black. The folder was renamed and the
game came back.
Technologies and skills
- JavaScript and three.js (WebGL) for the 3D board, camera views and graphics quality settings.
- WebSockets and host-authoritative state for multiplayer; deterministic replay of moves.
- Game rules as a state machine, separate from the drawing, so it can be tested without a browser.
- Tests I specified and the AI wrote: Node.js test suites, a headless two-client harness, and browser tests (jsdom and Puppeteer).
- Web Audio: the music is generated in code, with no recordings.
- Cloudflare hosting, and an installable app that plays offline (service worker).
- AI-assisted engineering with Claude Code in VS Code, under written standards.
What it does not claim
- It is a personal portfolio piece and skills demonstration, not a commercial product. It is free,
with no ads, no cookies and no sign-in.
- Online play with other people is switched off in the public version for now; you play the bots.
- The ideas and decisions are mine; the AI implemented and tested them under my direction.
125changes, Apr to Oct 2026
44test files
3bot difficulties
0third-party requests