Public: anyone can read this; the crew can change it.
Migrated from github.com/amirmushichge/pixel-plays
Snail Race rules: a tested `snail-race/race.js` where you pace a snail down a garden lane against three rivals, spending slime for bursts, from plain data, with a test file that runs in under a second #255
Check · Review · Land · Live done — Landed and live in production.
This adds the Snail Race rules in snail-race/race.js and a test file, snail-race/race.test.mjs, and nothing else. Tests. bun test snail-race/race.test.mjs gives 8 passing tests (44 assertions) in 45 ms.
shipped production is serving it deploy ab54f53
This adds the Snail Race rules in snail-race/race.js and a test file, snail-race/race.test.mjs, and nothing else.
Tests. bun test snail-race/race.test.mjs gives 8 passing tests (44 assertions) in 45 ms. The file calls the rules module directly and loads no page, renderer or server. The repo has no scripts/gate.ts or scripts/fast.ts, so I skipped both. bun x tsc --noEmit only printed its help text because the repo has no tsconfig, so it checked nothing. I ran no other test files.
Rules
- Setup:
start(seed)gives a 60 cm lane, a slime supply of 100 and three rivals with seeded pace curves. The same seed always gives the same rivals. - Rival pace: a rival's position comes from a closed-form formula, so it doesn't change with how time is sliced. Their finish times are fixed at the start.
- Steps: the beat falls every 0.5 s. A step within 0.1 s of a beat is on-beat: speed rises by 0.15 cm/s and slime refills by 5, up to the supply. An off-beat step cuts speed by 0.25 cm/s. Speed stays between 0.5 and 2 cm/s.
- Burst: a burst costs 40 slime and adds 1.5 cm/s for 3 s, on top of the speed cap. It is refused with
slime-shortwhen slime is under 40. - Finish: the race ends when all four snails have crossed. The result lists the places in order and your time. First place is the win line and any other place is the loss line.
- Refusals: a refused call returns the same state and says why.
I added one rule the issue didn't ask for: a burst is also refused while a previous one is still running (bursting), so bursts can't stack. Say if you'd rather they stack.
Not done, as the issue says: no page and no catalogue entry, and shell.js, index.html, town.js and rounds.mjs are untouched. The first attempt (#224) failed on the 600 s limit, which #227 and #233 address. This test file runs on its own in well under a second, so that limit shouldn't apply.
Try it: bun test snail-race/race.test.mjs.
🤖 Generated with Claude Code
Clean rules module: plain data in and out, no DOM, seeded rivals, closed-form rival positions independent of tick slicing, refusals return the same state with a reason. Tests cover each rule and run in 45 ms as stated. The extra bursting refusal is disclosed and reasonable. Nothing to change.
This adds the Snail Race rules in
snail-race/race.jsand a test file,snail-race/race.test.mjs, and nothing else.Tests.
bun test snail-race/race.test.mjsgives 8 passing tests (44 assertions) in 45 ms. The file calls the rules module directly and loads no page, renderer or server. The repo has noscripts/gate.tsorscripts/fast.ts, so I skipped both.bun x tsc --noEmitonly printed its help text because the repo has no tsconfig, so it checked nothing. I ran no other test files.Rules
start(seed)gives a 60 cm lane, a slime supply of 100 and three rivals with seeded pace curves. The same seed always gives the same rivals.slime-shortwhen slime is under 40.I added one rule the issue didn't ask for: a burst is also refused while a previous one is still running (
bursting), so bursts can't stack. Say if you'd rather they stack.Not done, as the issue says: no page and no catalogue entry, and
shell.js,index.html,town.jsandrounds.mjsare untouched. The first attempt (#224) failed on the 600 s limit, which #227 and #233 address. This test file runs on its own in well under a second, so that limit shouldn't apply.Try it:
bun test snail-race/race.test.mjs.🤖 Generated with Claude Code
Closes #239