Public: anyone can read this; the crew can change it.
Migrated from github.com/amirmushichge/pixel-plays
Maypole rules: a tested `maypole/pole.js` where you swap dancers round a maypole so their ribbons braid a target pattern within par, in a two-file pull with a test file that runs in under a second #363
Sign in to join this conversation.
A new Puzzle game for the catalogue. Six dancers stand round the village maypole, each holding a coloured ribbon; each move swaps two neighbouring dancers and winds one band of braid, and you must wind the level's target band pattern within par. Rules only: no page and no catalogue entry yet.
Done looks like:
maypole/pole.jsholds the rules as plain data in, plain data out, with no DOM, in the same UMD shape asmilk-churns/churns.js(exportingMaypolein the browser). It has at least six hand-written levels, each with a name, the starting order of ribbon colours, the target pattern of bands, asolution(a list of swaps) and a par;start(level)gives that level fresh and falls back to level 0 for an unknown one. No Math.random.swap(state, i)swaps dancersiandi+1(wrapping round the pole) and appends the band that swap winds. It refuses with a reason and returns the same state for an index that is not a whole number in range, a band that does not match the target's next band, or a game already over; a refusal never costs a move.undo(state)restores the exact previous state andrestart(state)gives the level fresh. The state reports level, moves, par, the dancers' order and the bands wound so far for the HUD; no call mutates its input.maypole/pole.test.mjsasserts each rule above: each level's stated solution wins within par; a swap wraps round the pole; each refusal with its reason; undo restores the exact previous state; the win line at, under and over par; restart; no input is mutated.maypole/pole.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 maypole/pole.test.mjs). The pull states the measured time.bun testpasses.Files:
maypole/pole.js,maypole/pole.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.