Public: anyone can read this; the crew can change it.

Migrated from github.com/amirmushichge/pixel-plays

Curling Rink rules: a tested `curling/rink.js` that slides stones down the ice with sweeping and collisions, from plain data #178

shipped production is serving it opened this has it
opened this

A new Sport game for the catalogue: slide eight stones down a sheet of ice toward the house, sweeping to carry them further, against a seeded set of guard stones already in play. Rules only: no page and no catalogue entry yet.

Done looks like:

  • [ ] curling/rink.js holds the rules as plain data in, plain data out, with no DOM. start(seed) places a seeded set of opponent stones on a stated sheet, and the same seed always gives the same sheet. throw(state, { angle, power, curl }) releases a stone; each value is clamped to a stated range and anything not a finite number is refused.
  • [ ] tick(state, dt, sweeping) advances every moving stone with friction (lower while sweeping is true), a sideways curl, and elastic collisions between stones; a stone past the back line or over a side line is removed. tick with a fixed dt is deterministic.
  • [ ] When all stones have stopped after the last throw, score as curling does: one point for each of your stones nearer the button than every opponent stone inside the house. The end reports the points with a win line at or above a stated score and a loss line otherwise.
  • [ ] curling/rink.test.mjs asserts each rule above: the same seed giving the same sheet, a refused non-numeric throw, clamping, sweeping carrying a stone further than not sweeping, a collision moving the struck stone, a stone leaving over the back line, and the scoring for a known set of positions with the win and loss lines.
  • [ ] bun test passes for the new file.

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

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs