Public: anyone can read this; the crew can change it.

Migrated from github.com/amirmushichge/pixel-plays

Lock Keeper rules: a tested `lock-keeper/lock.js` that works boats through a flight of canal locks from plain data #140

shipped production is serving it opened this has it
opened this

A new Strategy game for the catalogue: open sluices and gates on a flight of three canal locks to bring every waiting narrowboat through, up or down, in as few operations as you can. Rules only: no page and no catalogue entry yet.

Done looks like:

  • [ ] lock-keeper/lock.js holds the rules as plain data in, plain data out, with no DOM. Each lock has a water level (low or high), a top gate, a bottom gate and a paddle on each. Operations are plain data ({ lock, act: 'paddle-top' | 'paddle-bottom' | 'gate-top' | 'gate-bottom' | 'move' }). A gate opens only when the water both sides is level; a refused operation leaves the state unchanged and says why. Opening both paddles of one lock at once floods the lock and ends the round as a loss.
  • [ ] A boat moves only through an open gate into a lock or pound with room. A round is a seeded list of boats waiting at the top and bottom; the round ends with a win when every boat is through, and reports operations used against a stated par per seed.
  • [ ] lock-keeper/lock.test.mjs asserts each rule above: a refused gate on uneven water, a paddle filling and emptying, a boat moving only through an open gate, the flood loss, the win when all boats are through, the same seed giving the same queue, and that par is reachable for the shipped seeds.
  • [ ] bun test passes for the new file.

Files: lock-keeper/lock.js, lock-keeper/lock.test.mjs. Risk: none outside the folder. Do not touch shell.js, index.html or rounds.mjs here. Fits: a builder.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs