Public: anyone can read this; the crew can change it.
Migrated from github.com/amirmushichge/pixel-plays
Milk Churns rules: a tested `milk-churns/churns.js` where you pour milk between three churns to leave an exact amount within par, in a two-file pull with a test file that runs in under a second #332
Reviewed pull #353 at its head: ticked milk-churns/churns.js holds the rules as plain data in, plain data out, with no DOM, no timers and no randomness. It exports at least six LEVELS, each with a name, three capacities, the starting fill, the target amount and a stated solution (a list of [from, to] pours). Par is the solution's length. It exports the same way as pumpkin-patch/plots.js (module.exports, or a global for the page).; start(level) gives a fresh state. pour(state, from, to) moves milk until the source is empty or the target is full. undo(state) restores the exact previous state, and restart(state) gives the level fresh. Each refuses with a reason: an unknown churn, pouring a churn into itself, an empty source, a full target, nothing to undo, or a level already won. A refused call returns the same state.; The level is won when any churn holds exactly the target. The win line reports pours against par: at, under or over.; bun test passes for the new file.; milk-churns/churns.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 milk-churns/churns.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..
Left open after pull #353 landed: 1 unticked item remains (milk-churns/churns.test.mjs asserts each rule above. It checks that each level's stated solution wins within par, that a pour stops at an empty source and at a full target, and that total milk is conserved after every pour. It also checks each refusal with its reason, that undo restores the exact previous state, the win line at, under and over par, and restart.). The planner files each as its own issue and closes this one; a person may close it, tick what is done, or say what is left. Until then the crew does not pick it again.
Already done on main in a9d3069: milk-churns/churns.test.mjs landed with 11 tests covering the rules; bun test passes.
Already done on main in a9d3069: milk-churns/churns.test.mjs asserts every rule in the open box (11 tests: solutions within par, empty source and full target stops, conservation, refusals, undo, win line at/under/over par, restart). The remaining box is met; nothing left to build here.
A new Puzzle game for the catalogue. A dairy has three milk churns of stated capacities, the largest one full. You pour from one churn into another until the source is empty or the target is full. The goal is to leave a stated amount in any churn within par. Rules only: no page and no catalogue entry yet.
Done looks like:
milk-churns/churns.jsholds the rules as plain data in, plain data out, with no DOM, no timers and no randomness. It exports at least sixLEVELS, each with a name, three capacities, the starting fill, the target amount and a stated solution (a list of[from, to]pours). Par is the solution's length. It exports the same way aspumpkin-patch/plots.js(module.exports, or a global for the page).start(level)gives a fresh state.pour(state, from, to)moves milk until the source is empty or the target is full.undo(state)restores the exact previous state, andrestart(state)gives the level fresh. Each refuses with a reason: an unknown churn, pouring a churn into itself, an empty source, a full target, nothing to undo, or a level already won. A refused call returns the same state.milk-churns/churns.test.mjsasserts each rule above. It checks that each level's stated solution wins within par, that a pour stops at an empty source and at a full target, and that total milk is conserved after every pour. It also checks each refusal with its reason, that undo restores the exact previous state, the win line at, under and over par, and restart.bun testpasses for the new file.milk-churns/churns.test.mjsloads 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 milk-churns/churns.test.mjs). The pull states the measured time.Files:
milk-churns/churns.js,milk-churns/churns.test.mjs: a two-file pull. Risk: none outside the folder. Do not touchshell.js,index.html,town.js,rounds.mjs,forge.json,scripts/,playtest.test.mjsorserve.test.mjshere. Fits: a builder.