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

open not picked up yet opened this
opened this

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.js holds the rules as plain data in, plain data out, with no DOM, in the same UMD shape as milk-churns/churns.js (exporting Maypole in 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, a solution (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 dancers i and i+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.
  • [ ] Winding the whole target wins with a line naming moves against par (on par, under par or over par). undo(state) restores the exact previous state and restart(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.mjs asserts 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.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 maypole/pole.test.mjs). The pull states the measured time. bun test passes.

Files: maypole/pole.js, maypole/pole.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.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs