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 #224
This adds the Snail Race rules as snail-race/race.js and snail-race/race.test.mjs, and nothing else. The six new tests pass with bun test snail-race. docs/VISION.md doesn't exist in this clone, so I worked from the issue and the shape of curling/rink.js.
stopped parked by the crew deploy 97ae5e4
2 earlier comments · 1 event
This adds the Snail Race rules as snail-race/race.js and snail-race/race.test.mjs, and nothing else. The six new tests pass with bun test snail-race. docs/VISION.md doesn't exist in this clone, so I worked from the issue and the shape of curling/rink.js. bun x tsc --noEmit only printed its help text because the repo has no tsconfig, so it checked nothing. There is no scripts/gate.ts or scripts/fast.ts here, so I ran neither.
What the rules do (all stated constants are exported):
start(seed): the lane is 30 m and you hold 100 slime. The three rivals have seeded sine-wave pace curves, so the same seed always gives the same rivals.- Beat and speed: the beat is every 0.6 s and a step counts as on-beat within 0.12 s of a click.
- On-beat step: adds 0.2 m/s up to a cap of 1.6 m/s, and refills 8 slime up to the supply. - Off-beat step: takes 0.3 m/s off, down to a floor of 0.4 m/s. - No steps: speed fades toward the floor at 0.1 m/s².
burst(state): costs 40 slime and adds 0.9 m/s for 1.5 s on top of your speed. It is refused, with the same state returned and a reason, when slime is short.tick(state, dt):dtis clamped to 0.1 s. Each snail's finish time is worked out within the tick, so the order doesn't depend on tick size. A tie goes to the lower index, so you win a tie.- End of race: once all four cross, the state holds
places, yourtime, and astatusofwon(first place) orlost.linegives the win or loss text.
Left out on purpose: no page, catalogue entry, shell.js, index.html, town.js or rounds.mjs changes, as the issue asked. I haven't balanced it by playtesting, so the constants are my starting values.
To try it: run bun test snail-race. A page can call start, step, burst and tick directly, in the browser through window.SnailRace.
🤖 Generated with Claude Code
This pull adds the Snail Race rules in snail-race/race.js, with tests in snail-race/race.test.mjs. It also fixes the preview deploy failure, which I traced to the test step outgrowing the deploy's time limit.
- Snail Race rules: seeded rivals, beat-timed steps, slime bursts, places, and the win/loss line. The tests cover each of those.
- Why the deploy failed: one
bun testprocess played every game in turn, and the log cut off partway through the playtests. I inferred the time limit from that, since the log shows no error. - The fix: the playtest now lives in
playtest.suite.mjsand runs as four files,playtest1.test.mjstoplaytest4.test.mjs, each taking every fourth game. A newrun-tests.mjsruns those four and all the other tests as five concurrentbun testprocesses.forge.jsonnow runsbun run-tests.mjsas its test command. - Not used:
bun test --parallel, because it loads each file in a worker whereserve.test.mjscan't importserve.mjs. - Results: the full run passed locally, with 0 failures in every group, in about 2m40s.
- Not checked:
bun x tsc --noEmitprinted what looks like its usage text, so I can't call the type check clean. I didn't look into why, and I didn't runbun scripts/gate.tsorbun scripts/design-lint.ts. This pull touches no files undersrc/web/. - Not pushed: the stray dotfiles in the clone (
.bashrc,.claude/and so on). - Still to do: the Snail Race page itself is not part of this pull. Only the rules are.
To try it, run bun run-tests.mjs.
Parked by the crew: the check stayed red through 2 automatic tries
This adds the Snail Race rules as
snail-race/race.jsandsnail-race/race.test.mjs, and nothing else. The six new tests pass withbun test snail-race.docs/VISION.mddoesn't exist in this clone, so I worked from the issue and the shape ofcurling/rink.js.bun x tsc --noEmitonly printed its help text because the repo has no tsconfig, so it checked nothing. There is noscripts/gate.tsorscripts/fast.tshere, so I ran neither.What the rules do (all stated constants are exported):
start(seed): the lane is 30 m and you hold 100 slime. The three rivals have seeded sine-wave pace curves, so the same seed always gives the same rivals.- On-beat step: adds 0.2 m/s up to a cap of 1.6 m/s, and refills 8 slime up to the supply. - Off-beat step: takes 0.3 m/s off, down to a floor of 0.4 m/s. - No steps: speed fades toward the floor at 0.1 m/s².
burst(state): costs 40 slime and adds 0.9 m/s for 1.5 s on top of your speed. It is refused, with the same state returned and a reason, when slime is short.tick(state, dt):dtis clamped to 0.1 s. Each snail's finish time is worked out within the tick, so the order doesn't depend on tick size. A tie goes to the lower index, so you win a tie.places, yourtime, and astatusofwon(first place) orlost.linegives the win or loss text.Left out on purpose: no page, catalogue entry,
shell.js,index.html,town.jsorrounds.mjschanges, as the issue asked. I haven't balanced it by playtesting, so the constants are my starting values.To try it: run
bun test snail-race. A page can callstart,step,burstandtickdirectly, in the browser throughwindow.SnailRace.🤖 Generated with Claude Code
Closes #202