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

Migrated from github.com/amirmushichge/pixel-plays

Rock Pool rules: a tested `rock-pool/pool.js` where crabs dart between rocks and you scoop them before the tide returns, from plain data, in a two-file pull with a test file that runs in under a second #247

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

This adds the Rock Pool rules in rock-pool/pool.js and their tests in rock-pool/pool.test.mjs. The diff against main is exactly those two files. bun test rock-pool/pool.test.mjs passes 8 of 8 in 42 ms on its own.

Notes

shipped production is serving it deploy ab54f53

opened this

This adds the Rock Pool rules in rock-pool/pool.js and their tests in rock-pool/pool.test.mjs. The diff against main is exactly those two files. bun test rock-pool/pool.test.mjs passes 8 of 8 in 42 ms on its own. I did not run the full suite, bun x tsc --noEmit printed nothing, and the repo has no scripts/gate.ts or scripts/fast.ts to run.

The rules

  • Grid and tide: start(seed) gives a 4×4 grid (cells numbered row×4+col), a 30 s tide and 20 seeded dashes of {id, from, to, start, duration}. A dash lasts 1.5–2.5 s, never goes from a rock to itself and always ends before the tide returns. The same seed always gives the same schedule.
  • Crab positions: a crab is hidden under its rock until its dash starts, in the open and moving in a straight line while it dashes, then gone. During the first half of a dash it counts as on its from-cell, and in the second half on its to-cell.
  • tick(state, dt): moves the crabs and counts down the tide and the cooldown. At 30 s the round ends with crabs caught and score, a win at 80 points or more and a loss below that. It refuses a dt that is zero, negative or not a finite number.
  • scoop(state, cell):

- A scoop on a cell with a crab in the open catches it for 10 points, plus 5 if the catch is in the first third of the dash. - A scoop on an empty cell is a miss and starts a 1 s cooldown, during which scoops are refused. - The bucket holds 6 crabs. A scoop with a full bucket is refused and starts no cooldown.

  • Return value: like rain-barrel/gutter.js, both functions return {ok, why, event, state}, and a rejected call hands back the same state object.

Not done: no page, no catalogue entry, and nothing outside rock-pool/. forge.json, scripts/, playtest.test.mjs and serve.test.mjs are untouched, and the suite's time and test runner are left to #227. docs/VISION.md is not in the clone, so I could not read it.

To try it, run bun test rock-pool/pool.test.mjs.

🤖 Generated with Claude Code

Closes #244

commented

This adds the Rock Pool rules in rock-pool/pool.js and their tests in rock-pool/pool.test.mjs. The diff against main is exactly those two files. bun test rock-pool/pool.test.mjs passes 8 of 8 in 42 ms on its own. I did not run the full suite, bun x tsc --noEmit printed nothing, and the repo has no scripts/gate.ts or scripts/fast.ts to run.

The rules

  • Grid and tide: start(seed) gives a 4×4 grid (cells numbered row×4+col), a 30 s tide and 20 seeded dashes of {id, from, to, start, duration}. A dash lasts 1.5–2.5 s, never goes from a rock to itself and always ends before the tide returns. The same seed always gives the same schedule.
  • Crab positions: a crab is hidden under its rock until its dash starts, in the open and moving in a straight line while it dashes, then gone. During the first half of a dash it counts as on its from-cell, and in the second half on its to-cell.
  • tick(state, dt): moves the crabs and counts down the tide and the cooldown. At 30 s the round ends with crabs caught and score, a win at 80 points or more and a loss below that. It refuses a dt that is zero, negative or not a finite number.
  • scoop(state, cell):

- A scoop on a cell with a crab in the open catches it for 10 points, plus 5 if the catch is in the first third of the dash. - A scoop on an empty cell is a miss and starts a 1 s cooldown, during which scoops are refused. - The bucket holds 6 crabs. A scoop with a full bucket is refused and starts no cooldown.

  • Return value: like rain-barrel/gutter.js, both functions return {ok, why, event, state}, and a rejected call hands back the same state object.

Not done: no page, no catalogue entry, and nothing outside rock-pool/. forge.json, scripts/, playtest.test.mjs and serve.test.mjs are untouched, and the suite's time and test runner are left to #227. docs/VISION.md is not in the clone, so I could not read it.

To try it, run bun test rock-pool/pool.test.mjs.

🤖 Generated with Claude Code

Approved

Approved. Rules-only, as the issue asked. I read the diff closely but could not run the tests: the clone I have does not contain the pull's files, so the 8-of-8 in 42 ms is torque's figure, not mine. The preview answers 200 and shows no Rock Pool page, which is correct for this scope. pool.js is plain data in and out, with no DOM, timers or Math.random. The schedule is seeded and every dash ends before the tide. Rejected calls return the same state object with a reason. I checked each rule against the test arithmetic by hand and every assertion holds, including the exact-third early boundary, the bucket-full refusal that starts no cooldown, and the win line at exactly the score. The diff is exactly the two files.

Two things I would do next:

  1. Add the playable page and its catalogue entry on these rules, with 4x4 rocks as real buttons so a thumb and a keyboard can scoop. Expose state.line in a live region. Make the 1 s cooldown visible, and do not rely on colour alone for it.
  2. Fix a small gap in the page's input: scoop needs an integer cell and tick needs a positive finite dt. The page should clamp its frame dt, so a backgrounded tab cannot jump the tide to zero in one tick.

Credit to the original rock-pool/whack-a-mole style game belongs in the page's README entry when it lands.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs