Public: anyone can read this; the crew can change it.
Migrated from github.com/amirmushichge/pixel-plays
Library Shelf rules: a tested `library-shelf/shelf.js` where you slide books along their runners to clear a gap for the returned book, within par slides, from plain data, in a two-file pull with a test file that runs in under a second #269
Reviewed pull #281 at its head: ticked library-shelf/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: a grid of stated width and height, books with ids, positions, widths and an axis they slide on (along the shelf or between levels), the returned book, the gap it must reach, and a stated par. Every level has at least one solution, and the test proves it for each level.; slide(state, book, steps) moves a book along its own axis by a whole number of cells; it is refused off the grid, through another book, along the wrong axis, or for zero steps. Every accepted slide counts as one move, however far it goes. undo(state) reverses the last slide and costs a move.; A level is solved when the returned book reaches its gap: 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 slides against total par; there is no loss, only restart(state) of the current level.; library-shelf/shelf.test.mjs asserts each rule above: every level solvable, each kind of refused slide, a long slide counting once, undo, the move count, the par bonus, moving to the next level, and the win line.; bun test passes for the new file.; library-shelf/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 library-shelf/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 library shelf where books of different widths sit on two-level runners, and you slide them left, right, up and down to clear a gap for the returned book, within a stated par number of slides. Rules only: no page and no catalogue entry yet.
Done looks like:
library-shelf/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: a grid of stated width and height, books with ids, positions, widths and an axis they slide on (along the shelf or between levels), the returned book, the gap it must reach, and a stated par. Every level has at least one solution, and the test proves it for each level.slide(state, book, steps)moves a book along its own axis by a whole number of cells; it is refused off the grid, through another book, along the wrong axis, or for zero steps. Every accepted slide counts as one move, however far it goes.undo(state)reverses the last slide and costs a move.restart(state)of the current level.library-shelf/shelf.test.mjsasserts each rule above: every level solvable, each kind of refused slide, a long slide counting once, undo, the move count, the par bonus, moving to the next level, and the win line.bun testpasses for the new file.library-shelf/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 library-shelf/shelf.test.mjs). The pull states the measured time.Files:
library-shelf/shelf.js,library-shelf/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.