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

Migrated from github.com/amirmushichge/pixel-plays

Rain Barrel rules: a tested `rain-barrel/gutter.js` where rain runs off a roof's gutters and you slide one barrel under each spout before it overflows the yard, from plain data #226

Merged opened this

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

Merged

I added the Rain Barrel rules in rain-barrel/gutter.js, with rain-barrel/gutter.test.mjs covering them. The new file's 11 tests pass. bun x tsc --noEmit printed only its usage text, so I can't say the type check ran clean.

Notes

shipped production is serving it deploy ab54f53

opened this

I added the Rain Barrel rules in rain-barrel/gutter.js, with rain-barrel/gutter.test.mjs covering them. The new file's 11 tests pass. bun x tsc --noEmit printed only its usage text, so I can't say the type check ran clean. This repo has no scripts/gate.ts or scripts/fast.ts, so those weren't run.

Stated numbers

  • 5 spouts, numbered 0–4 from the left.
  • Barrel capacity of 4 drops.
  • A round of 40 ticks.
  • Emptying costs 2 ticks.
  • Each drop caught scores 10.
  • Emptying a full barrel scores a bonus of 25.
  • The puddle limit is 8.

Rules

  • Schedule: start(seed) builds the schedule in seeded bursts. Each burst is 2–4 drips from one spout, then 0–2 dry ticks. The same seed always gives the same schedule.
  • Moving: move(state, spout) refuses a spout off the row, or any move during a round that's over or while the barrel is emptying, and returns the same state with a reason.
  • Ticking: tick(state) fills the barrel when the drop falls on the spout above it. Any other drop adds one to the puddle. A full barrel catches nothing.
  • Emptying: empty(state) advances 2 ticks, and rain keeps falling while it pours, so those drops reach the puddle. A full barrel earns the bonus. An empty barrel is refused as already-empty.
  • Ending: the loss comes the moment the puddle reaches 8, with the line "Yard flooded". The win comes when tick 40 passes under 8, with the line "Yard dry".

Every call returns { ok, why, event, state }, the same shape as bunting/line.js. There's no page and no catalogue entry, and I didn't touch shell.js, index.html, town.js or rounds.mjs.

To try it, run bun test rain-barrel.

Closes #219

4 earlier comments · 3 events
commented

I added the Rain Barrel rules in rain-barrel/gutter.js, with rain-barrel/gutter.test.mjs covering them. The new file's 11 tests pass. bun x tsc --noEmit printed only its usage text, so I can't say the type check ran clean. This repo has no scripts/gate.ts or scripts/fast.ts, so those weren't run.

Stated numbers

  • 5 spouts, numbered 0–4 from the left.
  • Barrel capacity of 4 drops.
  • A round of 40 ticks.
  • Emptying costs 2 ticks.
  • Each drop caught scores 10.
  • Emptying a full barrel scores a bonus of 25.
  • The puddle limit is 8.

Rules

  • Schedule: start(seed) builds the schedule in seeded bursts. Each burst is 2–4 drips from one spout, then 0–2 dry ticks. The same seed always gives the same schedule.
  • Moving: move(state, spout) refuses a spout off the row, or any move during a round that's over or while the barrel is emptying, and returns the same state with a reason.
  • Ticking: tick(state) fills the barrel when the drop falls on the spout above it. Any other drop adds one to the puddle. A full barrel catches nothing.
  • Emptying: empty(state) advances 2 ticks, and rain keeps falling while it pours, so those drops reach the puddle. A full barrel earns the bonus. An empty barrel is refused as already-empty.
  • Ending: the loss comes the moment the puddle reaches 8, with the line "Yard flooded". The win comes when tick 40 passes under 8, with the line "Yard dry".

Every call returns { ok, why, event, state }, the same shape as bunting/line.js. There's no page and no catalogue entry, and I didn't touch shell.js, index.html, town.js or rounds.mjs.

To try it, run bun test rain-barrel.

commented

I haven't changed anything or pushed. The failure doesn't look like it comes from this pull.

  • What the pull changes: it only adds rain-barrel/gutter.js and its test file.
  • Where the log stopped: it ended after serve.test.mjs passed the share-card test. The next test, "every committed card is what the games render now", renders every game's card, and that was running when the 600 s limit hit.
  • What I ran here: bun test serve.test.mjs passed all 72 tests, but took about 89 s on its own. The deploy machine ran well over six times slower than that, which points to a loaded host rather than a hang.
  • Why my code can't cause it: the pull adds nothing to the catalogue, shell.js or index.html, so the card tests don't see it.

Pushing again would only re-run the same check. If it times out a second time, the card rendering in serve.test.mjs is the place to look. Its cost grows with every game added, and that's a separate issue from this pull.

the crew's run was interrupted: restart, resumes on the next pass — cancelled
commented

Pull #226 adds only the rules for Rain Barrel, with no page, and I changed no code in this turn. The preview deploy log you sent stops partway through the playtest suite, before any failure appears. I couldn't find the cause.

  • What changed: rain-barrel/gutter.js holds the seeded gutter rain and the one barrel to slide. rain-barrel/gutter.test.mjs tests them.
  • What I checked: bun test rain-barrel serve.test.mjs passes, 83 tests. I did not finish a full playtest.test.mjs run here: it timed out at 120 seconds, and the output file I read afterwards held only the unrelated ls and git show output. bun x tsc --noEmit only printed its help text, so that check did not run. I didn't run scripts/gate.ts.
  • Why it probably isn't this change: The playtest only boots folders that contain an index.html, and rain-barrel/ has none yet. The change touches no files outside rain-barrel/.
  • Push: The branch is already up to date with the remote, so there was nothing new to push. Git reports the remote-tracking ref as "gone", but git push says everything is up to date.
  • What I left out: The playable page, the catalogue entry, the scripted round in rounds.mjs and the og image. Those are for a follow-up.

To try it, run bun test rain-barrel. If the preview deploy still fails, I need the part of the log that shows the failing test.

Changes requested — before the latest push

The rules are sound and match the issue (rules only, same result shape as bunting/line.js, 11 tests). One change to make: pouring is dead state. empty() sets it and loops until it is 0, so no state the API returns ever has pouring > 0. The 'emptying' refusals in move and empty, and the pouring === 0 catch guard, can only be reached by hand-building a state. No test covers them either. Either make emptying span real ticks (empty starts it, tick advances it, move and empty are refused meanwhile, with tests for each), or drop pouring and those branches and loop for EMPTY_TICKS in empty. Also add a test that asserts the 'bonus' event and one where the yard floods or the round ends during an empty(). This pull adds no page, catalogue entry or tty door, which matches its stated scope. The follow-up that adds them must also carry the README and the preview.

commented

I removed the dead pouring state, as juniper's second option suggested. The push is e530393.

  • pouring removed. empty() now empties the barrel at once and runs EMPTY_TICKS ticks with catching switched off. It stops early if the yard floods or the round ends. The unreachable "emptying" refusals in move and empty are gone, and so is the pouring === 0 catch guard.
  • Where rules stay the same. The state has no pouring field any more. Emptying still costs EMPTY_TICKS ticks of rain that nothing catches, and a full barrel still scores the bonus. I did not make emptying span real ticks, because the page has no use for that yet.
  • New tests. The full-barrel test now asserts the 'bonus' event, and the part-filled test asserts 'emptied'. A flood during empty() ends the round with a 'lost' event after one tick. A round ending during empty() is a win with the bonus still scored.
  • Checks. bun test rain-barrel passes, 13 tests. I did not run the full suite or scripts/gate.ts. bun x tsc --noEmit printed its help text instead of checking, so the type check did not run.
  • Not done. The playable page, catalogue entry, README and preview are left for the follow-up pull, as before.
Approved

The earlier ask (remove the dead pouring state and its unreachable refusals) is met: the diff has no pouring field, empty() runs EMPTY_TICKS ticks with catching off and stops on a flood or round end, and the new tests cover the bonus, emptied, lost and won events. The rules-only scope matches the issue title. I judged from the diff, because this clone does not contain rain-barrel/, so I did not run the tests myself. There is no page, so there is nothing for a phone or keyboard to reach yet. Two things I would do next: 1) Non-blocking: wrap the long comment on the scoring rule at the top of gutter.js (the line about drops while the barrel is full or being emptied) to match the width of the other comments. 2) Non-blocking: the follow-up pull should add the playable page with a keyboard-reachable spout row, 44px touch targets on 360px, a text status line (state.line already exists for this), the catalogue entry, and the README.

commented

Left #219 open: 5 unticked items remain (rain-barrel/gutter.js holds the rules as plain data in, plain data out, with no DOM. start(seed) gives a stated number of spouts, a stated barrel capacity, a stated round length in ticks and a seeded schedule of which spout drips when; the same seed always gives the same schedule.; move(state, spout) places the barrel under that spout; a spout off the row is refused and changes nothing. tick(state) advances time: a drop from the spout above the barrel fills it by one, any other drop adds one to the yard puddle. A full barrel catches nothing until empty(state), which costs a stated number of ticks.; Each drop caught scores a stated amount and each barrel emptied full scores a stated bonus. The game ends with a win line when the round length passes with the puddle under a stated limit, and a loss line when the puddle reaches it.; …).

Approved

Rules-only pull, as the issue asks. I read every changed line and found no security surface: it is pure functions on plain data, with no I/O, no eval and no secrets. The seed is coerced to a finite unsigned integer, and spout input is validated with Number.isInteger and a range check. Rejected calls return the same state object with a reason. Each rule has a test, including a flood or a round end during empty(). I did not run the tests myself. Non-blocking: the long comment at the top of gutter.js is not wrapped to the width of the others. The playable page, catalogue entry, README and tty door belong to the follow-up.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs