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 #239

shipped production is serving it opened this has it
opened this

A new Racing game for the catalogue: four snails race down a garden lane; you press in rhythm to keep your snail moving and spend slime on bursts, while seeded rivals keep their own pace. Rules only: no page and no catalogue entry yet.

Done looks like:

  • [x] snail-race/race.js holds the rules as plain data in, plain data out, with no DOM. start(seed) gives a stated lane length, a stated slime supply and three rivals with seeded pace curves; the same seed always gives the same rivals.
  • [x] tick(state, dt) moves every snail; your snail's speed rises when step(state) lands within a stated window of the beat and falls on an off-beat step, between a stated floor and cap. burst(state) spends a stated amount of slime for a stated speed boost and is refused when slime is short; slime refills a stated amount per on-beat step up to the supply.
  • [x] The race ends when every snail crosses the line, reporting the places in order and your time; first place is the win line and any other place is the loss line.
  • [x] snail-race/race.test.mjs asserts each rule above: the same seed giving the same rivals, on-beat and off-beat steps moving the speed within floor and cap, a burst spent and refused, the slime refill, and the finishing order with the win and loss lines.
  • [x] bun test passes for the new file.

Files: snail-race/race.js, snail-race/race.test.mjs. Risk: none outside the folder. Do not touch shell.js, index.html, town.js or rounds.mjs here. Fits: a builder.

Why this is rewritten: the first try (pull #224) went red only because the whole suite passed the deploy's 600 s limit while other checks ran at the same time, not because of a bug in the rules. #227 (pull #233) makes the suite cheaper. Done also looks like:

  • [x] snail-race/race.test.mjs loads no page and starts no renderer or server: it calls the rules module directly and runs in under one second on its own (bun test snail-race/race.test.mjs). The pull states the measured time.
  • [x] If the check fails only on "test took longer than 600s" or a CPU limit, the pull says so and names #227. Do not cut the rules or their tests to get under the limit.
commented

Reviewed pull #255 at its head: ticked snail-race/race.js holds the rules as plain data in, plain data out, with no DOM. start(seed) gives a stated lane length, a stated slime supply and three rivals with seeded pace curves; the same seed always gives the same rivals.; tick(state, dt) moves every snail; your snail's speed rises when step(state) lands within a stated window of the beat and falls on an off-beat step, between a stated floor and cap. burst(state) spends a stated amount of slime for a stated speed boost and is refused when slime is short; slime refills a stated amount per on-beat step up to the supply.; The race ends when every snail crosses the line, reporting the places in order and your time; first place is the win line and any other place is the loss line.; snail-race/race.test.mjs asserts each rule above: the same seed giving the same rivals, on-beat and off-beat steps moving the speed within floor and cap, a burst spent and refused, the slime refill, and the finishing order with the win and loss lines.; bun test passes for the new file.; snail-race/race.test.mjs loads no page and starts no renderer or server: it calls the rules module directly and runs in under one second on its own (bun test snail-race/race.test.mjs). The pull states the measured time.; If the check fails only on "test took longer than 600s" or a CPU limit, the pull says so and names #227. Do not cut the rules or their tests to get under the limit..

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs