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

Migrated from github.com/amirmushichge/pixel-plays

Bottle Bank rules: a tested `bottle-bank/bins.js` where you swing a conveyor chute to sort coloured bottles into the right bins before three cracks end the shift, from plain data, in a two-file pull with a test file that runs in under a second #318

Merged opened this

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

Merged

This adds the Bottle Bank rules and their tests, and nothing else: bottle-bank/bins.js and bottle-bank/bins.test.mjs. The 9 tests pass; bun test bottle-bank/bins.test.mjs ran in 42 ms. I did not run bun x tsc --noEmit: the repo has no tsconfig, so it only printed its help text.

Notes

shipped production is serving it deploy ab54f53

opened this

This adds the Bottle Bank rules and their tests, and nothing else: bottle-bank/bins.js and bottle-bank/bins.test.mjs. The 9 tests pass; bun test bottle-bank/bins.test.mjs ran in 42 ms. I did not run bun x tsc --noEmit: the repo has no tsconfig, so it only printed its help text. There is no scripts/gate.ts or scripts/fast.ts in this clone, so I ran neither.

Rules

  • Shape: it follows the Pancake Griddle pattern: plain data in, plain data out, no DOM or timers. Calls return {ok, state, why}, and a refused call returns the same state object.
  • Seed: start(seed) builds 24 bottles in three colours (clear, green, brown). All randomness comes from a seeded mulberry32, so the same seed gives the same shift.
  • Belt: it is 10 cells long. Gaps between bottles are 3–6 cells, and the first bottle starts 4 cells back.
  • Speed: it is 1 cell per tick, 2 after 8 bottles have dropped and 3 after 16.
  • Dropping: step(state) moves every bottle by the current speed. A bottle that reaches the end drops into the bin the chute faces, furthest bottle first. The gap minimum of 3 matches the top speed, so at most one bottle drops per tick.
  • Aiming: aim(state, bin) takes a bin from 0 to 2. It refuses an unknown bin with bad-bin and a finished shift with game-over.
  • Scoring: a right bin scores 1 point and extends the streak. Streaks of 3, 5 and 8 pay bonuses of 2, 3 and 5. A wrong bin is a crack and resets the streak.
  • End of shift: the shift ends on the third crack, or when the last bottle drops. The end line reads Shift over: N sorted, C cracks, best streak B, score S.

What I chose not to do: no page, catalogue entry or change outside bottle-bank/.

To try it: bun test bottle-bank/bins.test.mjs.

The tests cover the same seed giving the same bottles and the same shift, and the speed rises at 8 and 16 drops. They also cover right and wrong drops, the streak bonuses, each refusal, both ways the shift ends and the end line.

🤖 Generated with Claude Code

Closes #315

commented

This adds the Bottle Bank rules and their tests, and nothing else: bottle-bank/bins.js and bottle-bank/bins.test.mjs. The 9 tests pass; bun test bottle-bank/bins.test.mjs ran in 42 ms. I did not run bun x tsc --noEmit: the repo has no tsconfig, so it only printed its help text. There is no scripts/gate.ts or scripts/fast.ts in this clone, so I ran neither.

Rules

  • Shape: it follows the Pancake Griddle pattern: plain data in, plain data out, no DOM or timers. Calls return {ok, state, why}, and a refused call returns the same state object.
  • Seed: start(seed) builds 24 bottles in three colours (clear, green, brown). All randomness comes from a seeded mulberry32, so the same seed gives the same shift.
  • Belt: it is 10 cells long. Gaps between bottles are 3–6 cells, and the first bottle starts 4 cells back.
  • Speed: it is 1 cell per tick, 2 after 8 bottles have dropped and 3 after 16.
  • Dropping: step(state) moves every bottle by the current speed. A bottle that reaches the end drops into the bin the chute faces, furthest bottle first. The gap minimum of 3 matches the top speed, so at most one bottle drops per tick.
  • Aiming: aim(state, bin) takes a bin from 0 to 2. It refuses an unknown bin with bad-bin and a finished shift with game-over.
  • Scoring: a right bin scores 1 point and extends the streak. Streaks of 3, 5 and 8 pay bonuses of 2, 3 and 5. A wrong bin is a crack and resets the streak.
  • End of shift: the shift ends on the third crack, or when the last bottle drops. The end line reads Shift over: N sorted, C cracks, best streak B, score S.

What I chose not to do: no page, catalogue entry or change outside bottle-bank/.

To try it: bun test bottle-bank/bins.test.mjs.

The tests cover the same seed giving the same bottles and the same shift, and the speed rises at 8 and 16 drops. They also cover right and wrong drops, the streak bonuses, each refusal, both ways the shift ends and the end line.

🤖 Generated with Claude Code

Approved

The rules match the issue and follow the Pancake Griddle pattern. Seeded mulberry32 with no Math.random or timers. Refused calls return the same state object with a reason. The streak bonuses, both ways the shift ends and the end line are each tested, and the tests would fail without them. Torque reports 42 ms for the test file. I did not run it, and I did not open the preview or the screenshots. The pull adds no page, so there is nothing to see there.

Two things I would do next:

  1. Add the playable page: a keyboard-reachable chute with three large touch targets (usable at 360px and with a screen reader), and the end line in an aria-live region. Add the catalogue entry with it.
  2. Add a short credit line to the page and README, as the direction asks, if the sorting-conveyor idea comes from an original game. The sibling rules files carry no such line either, so I am not blocking on it.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs