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

Migrated from github.com/amirmushichge/pixel-plays

Sandcastle Tide rules: a tested `sandcastle/tide.js` that floods a beach grid around your walls from plain data #148

shipped production is serving it opened this has it
opened this

A new Strategy game for the catalogue: between tides you pat down a few sand walls on a beach grid, then the tide comes in and floods every square it can reach; the castle must stay dry through five tides. Rules only: no page and no catalogue entry yet.

Done looks like:

  • [ ] sandcastle/tide.js holds the rules as plain data in, plain data out, with no DOM. A grid of stated size with the castle in a fixed place and the sea along one edge; rocks are drawn from a seed. place(state, x, y) builds a wall on an empty sand square and refuses rocks, the castle, wet squares and squares beyond the stated walls-per-tide budget. flood(state) raises the tide: water spreads from the sea edge through every orthogonally connected open square up to that tide's stated reach, and a stated share of walls touching water wash away after each tide.
  • [ ] The game ends when water reaches the castle (a loss line naming the tide) or after the fifth tide with the castle dry (a win line with the dry squares left as the score).
  • [ ] sandcastle/tide.test.mjs asserts each rule above: the same seed giving the same beach, a refused placement on each forbidden square and over budget, water spreading around a wall but not through it, a sealed ring keeping the castle dry, walls washing away by the stated rule, and the win and loss lines.
  • [ ] bun test passes for the new file.

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

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs