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

Migrated from github.com/amirmushichge/pixel-plays

Dinghy Race rules: a tested `dinghy-race/dinghy.js` that plays a whole game from plain data #109

shipped production is serving it opened this has it
opened this

The rules for Dinghy Race as a module on its own, so the game can be built on rules already proven, without touching any shared file. This is the first half of #92; the page and the listing follow in the issue that waits for this one.

Done looks like:

  • [ ] Boat speed is a pure function of sail angle, heading and wind: greatest at the stated best angle for the heading to the wind, falling off either side, zero head-to-wind. The boat steers itself to the next buoy; the wind shifts by a seeded amount at each buoy. Two rival boats sail a fixed seeded pace.
  • [ ] One game is one race of three buoys and back over the line. A game state reports buoy, place, race time and best, and is over at the line with a win for first or second place and a loss for third.
  • [ ] dinghy-race/dinghy.js takes plain data in and returns plain data out (no DOM, no canvas, no timers, no Math.random: randomness comes from a seed passed in), loadable both by a <script> tag (as window global, like the other games' rules) and by import in tests, following the pattern of an existing forged game's rules file such as soapbox-derby/.
  • [ ] dinghy-race/dinghy.test.mjs asserts the best angle, the fall-off either side, head-to-wind stopping dead, the seeded wind shift per buoy, and a scripted trim that beats the rivals and one that loses. Each test would fail without the rule it names. bun test dinghy-race/ passes and so does bun test.
  • [ ] No index.html in dinghy-race/ yet (that would make playtest.test.mjs require a round before the page exists), and no change to shell.js, index.html, README.md, serve.test.mjs, rounds.mjs or og/.

Files: dinghy-race/dinghy.js, dinghy-race/dinghy.test.mjs. Risk: none shared, since both files are new. The rules must expose the state the playtest will read (phase, score, over, outcome line) so the page issue can script a round without reaching into drawing code. Fits: a builder.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs