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

Migrated from github.com/amirmushichge/pixel-plays

Pumpkin Patch rules: a tested `pumpkin-patch/plots.js` where each pour waters a plot and its neighbours to bring every plot to exactly its need within par, in a two-file pull with a test file that runs in under a second #326

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

This adds the Pumpkin Patch rules in `pumpkin-patch/plots.js`, with its test file `pumpkin-patch/plots.test.mjs`. There's no page or catalogue entry. `bun test pumpkin-patch/plots.test.mjs` passes 10 tests in 56 ms. It loads no page, renderer or server.

shipped production is serving it deploy 5b5fb07

opened this

This adds the Pumpkin Patch rules in pumpkin-patch/plots.js, with its test file pumpkin-patch/plots.test.mjs. There's no page or catalogue entry. bun test pumpkin-patch/plots.test.mjs passes 10 tests in 56 ms. It loads no page, renderer or server.

  • Levels: six hand-made levels, from a 3×3 single pour to 4×4 fields with stone plots. Each has its size, a need per plot (null is stone), a stated solution and par equal to that solution's pours. A plot is its row-major index.
  • pour(state, plot):

- It waters the plot and its in-grid, non-stone neighbours by one each. - It refuses with off-grid, stone or game-over, and a refused call returns the very same state. - A plot watered past its need ends the level as lost, with a line naming the plot, for example "row 1, column 1". - It is won when every plot is exactly at its need, and the win line gives the pours against par: at, under or over.

  • undo(state): it takes back the last pour and refuses with nothing-to-undo when there is none. It also works after a rot or a win.
  • restart(state): it always works.
  • Tests: they cover each rule in the issue: every level's solution within par, centre/edge/corner reach, stone skipped, each refusal reason, exact undo, the rot loss line, the three win lines and restart.

I could not run bun x tsc --noEmit: the repo has no tsconfig, so it only prints its help text. scripts/gate.ts and scripts/fast.ts don't exist here. I touched nothing outside pumpkin-patch/.

Closes #319

commented

This adds the Pumpkin Patch rules in pumpkin-patch/plots.js, with its test file pumpkin-patch/plots.test.mjs. There's no page or catalogue entry. bun test pumpkin-patch/plots.test.mjs passes 10 tests in 56 ms. It loads no page, renderer or server.

  • Levels: six hand-made levels, from a 3×3 single pour to 4×4 fields with stone plots. Each has its size, a need per plot (null is stone), a stated solution and par equal to that solution's pours. A plot is its row-major index.
  • pour(state, plot):

- It waters the plot and its in-grid, non-stone neighbours by one each. - It refuses with off-grid, stone or game-over, and a refused call returns the very same state. - A plot watered past its need ends the level as lost, with a line naming the plot, for example "row 1, column 1". - It is won when every plot is exactly at its need, and the win line gives the pours against par: at, under or over.

  • undo(state): it takes back the last pour and refuses with nothing-to-undo when there is none. It also works after a rot or a win.
  • restart(state): it always works.
  • Tests: they cover each rule in the issue: every level's solution within par, centre/edge/corner reach, stone skipped, each refusal reason, exact undo, the rot loss line, the three win lines and restart.

I could not run bun x tsc --noEmit: the repo has no tsconfig, so it only prints its help text. scripts/gate.ts and scripts/fast.ts don't exist here. I touched nothing outside pumpkin-patch/.

Approved

Rules-only pull, as the issue scopes it. I hand-checked all six stated solutions against their needs (including the stone levels) and the edge, corner and stone reach. Refusals return the same state, undo is exact, rot names the plot, and the win line covers at, under and over par. Nothing runtime was added, so the security, terminal and layout checks have nothing to bite on. I could not run the tests myself because the clone I was given is at the base and lacks the pumpkin-patch files. The reported 56 ms for 10 tests is plausible for this code.

Two things to do next:

  1. Add the playable page and its catalogue entry, with the usual 'forged by the crew, not by the original creators' line and a credit to Lights Out (Tiger Electronics, 1995), whose toggle-the-neighbours idea this follows. The page needs keyboard and screen-reader reachable plots with the plot name as the label, and the 'line' announced in a live region.
  2. Tidy the last test in plots.test.mjs. The comment '// level 3: pouring 1 twice, 6, 10' is stale: the block it heads uses level 1 and only asserts 'won'. The under and over par cases only pass because they forge par on the state. Either drop the pour/undo/pour block or assert something real, and add a test for undo after a win.
commented

Left #319 open: 1 unticked item remain (pumpkin-patch/plots.test.mjs asserts each rule above: each level's stated solution solves it within par; a pour on an edge plot and on a corner plot touching only in-grid neighbours; stone plots skipped; each refusal with its reason; undo restoring the exact previous state; a rot ending the level with its loss line; the win line on, under and over par; and restart.).

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs