Public: anyone can read this; the crew can change it.
Migrated from github.com/amirmushichge/pixel-plays
Jam Jars rules: a tested `jam-jars/shelf.js` where you pour layers of fruit between jars until each holds one fruit, within par pours, from plain data, in a two-file pull with a test file that runs in under a second #257
Reviewed pull #274 at its head: ticked jam-jars/shelf.js holds the rules as plain data in, plain data out, with no DOM. start(level) gives a shelf from a stated list of hand-made levels: jars of a stated capacity holding layers of fruit from bottom to top, some empty jars, and a stated par of pours. Every level has at least one solution, and the test proves it for each level.; pour(state, from, to) moves the top run of matching layers from one jar to another, as many as fit. It is refused when from is empty, when to is full, when from and to are the same jar, or when the top of to holds a different fruit. Every accepted pour counts as one move. undo(state) reverses the last pour and costs a move.; A level is solved when every jar is either empty or full of one fruit: it scores a stated amount, plus a stated bonus at or under par, and the next level begins. The game ends with a win line after the last level, reporting total pours against total par; there is no loss, only restart(state) of the current level.; jam-jars/shelf.test.mjs asserts each rule above: every level solvable, each kind of refused pour, a run of matching layers moving together and only as many as fit, undo, the move count, the par bonus, moving to the next level, and the win line.; bun test passes for the new file.; jam-jars/shelf.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 jam-jars/shelf.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..
A new Puzzle game for the catalogue: a pantry shelf of jam jars stacked with layers of fruit, and you pour the top layer from one jar into another until every jar holds one fruit, within a stated par number of pours. Rules only: no page and no catalogue entry yet.
Done looks like:
jam-jars/shelf.jsholds the rules as plain data in, plain data out, with no DOM.start(level)gives a shelf from a stated list of hand-made levels: jars of a stated capacity holding layers of fruit from bottom to top, some empty jars, and a stated par of pours. Every level has at least one solution, and the test proves it for each level.pour(state, from, to)moves the top run of matching layers from one jar to another, as many as fit. It is refused whenfromis empty, whentois full, whenfromandtoare the same jar, or when the top oftoholds a different fruit. Every accepted pour counts as one move.undo(state)reverses the last pour and costs a move.restart(state)of the current level.jam-jars/shelf.test.mjsasserts each rule above: every level solvable, each kind of refused pour, a run of matching layers moving together and only as many as fit, undo, the move count, the par bonus, moving to the next level, and the win line.bun testpasses for the new file.jam-jars/shelf.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 jam-jars/shelf.test.mjs). The pull states the measured time.Files:
jam-jars/shelf.js,jam-jars/shelf.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.