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

opened this

Merged 32d 21h ago, live in production

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

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 · 1 event
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.

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.
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.; …).

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs