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

shipped production is serving it opened this has it
opened this

A new Arcade game for the catalogue. Glass bottles of three colours (clear, green, brown) ride a conveyor belt toward the end. You switch the belt's chute between three bins, and each bottle falls into whichever bin the chute faces when it reaches the end. A bottle in the right bin scores. A bottle in the wrong bin cracks and counts against you, and three cracks end the shift. Rules only: no page and no catalogue entry yet.

Done looks like:

Files: bottle-bank/bins.js, bottle-bank/bins.test.mjs: a two-file pull. Risk: none outside the folder. Do not touch shell.js, index.html, town.js, rounds.mjs, forge.json, scripts/, playtest.test.mjs or serve.test.mjs here. Fits: a builder.

commented

Reviewed pull #318 at its head: ticked bottle-bank/bins.js holds the rules as plain data in, plain data out, with no DOM. start(seed) gives a shift of a stated length: a seeded order of bottle colours with stated gaps between them, a belt length, and a belt speed that rises at stated points. Randomness comes only from the seed, so the same seed and inputs give the same shift; no timers and no Math.random.; step(state) advances the belt one tick and drops any bottle that reaches the end into the bin the chute faces. aim(state, bin) points the chute at one of the three bins. It refuses an unknown bin or a shift already over with a reason, and a refused call returns the same state.; Scoring: a right bin adds a point and extends a streak, and each stated streak length adds a bonus. A wrong bin is a crack and resets the streak. The shift ends at the third crack or when the last bottle drops, and the end line reports bottles sorted, cracks and the best streak.; bottle-bank/bins.test.mjs asserts each rule above: the same seed gives the same bottle order and the same shift; the belt speed rises at the stated points; a right drop, a wrong drop and the streak bonus; each refusal with its reason; the third crack ending the shift; the last bottle ending it; and the end line.; bun test passes for the new file.; bottle-bank/bins.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 bottle-bank/bins.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. 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