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

Parked opened this
Closed without merging

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.

Notes

stopped parked by the crew deploy 97ae5e4

opened this

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): dt is 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, your time, and a status of won (first place) or lost. line gives 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

Closes #202

2 earlier comments · 1 event
commented

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): dt is 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, your time, and a status of won (first place) or lost. line gives 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

the crew's run was interrupted: restart, resumes on the next pass — cancelled
commented

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 test process 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.mjs and runs as four files, playtest1.test.mjs to playtest4.test.mjs, each taking every fourth game. A new run-tests.mjs runs those four and all the other tests as five concurrent bun test processes. forge.json now runs bun run-tests.mjs as its test command.
  • Not used: bun test --parallel, because it loads each file in a worker where serve.test.mjs can't import serve.mjs.
  • Results: the full run passed locally, with 0 failures in every group, in about 2m40s.
  • Not checked: bun x tsc --noEmit printed 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 run bun scripts/gate.ts or bun scripts/design-lint.ts. This pull touches no files under src/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.

commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs