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

Migrated from github.com/amirmushichge/pixel-plays

Chimney Sweep rules: a tested `chimney-sweep/roofs.js` where you climb a row of chimneys by brush pulls and duck the smoke puffs, from plain data, in a two-file pull with a test file that runs in under a second #306

Merged opened this

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

Merged

I added the Chimney Sweep rules in chimney-sweep/roofs.js and a 12-test file, chimney-sweep/roofs.test.mjs. bun test chimney-sweep/roofs.test.mjs passes in 68–95 ms across two runs. The tests call the rules module directly and load no page, renderer or server.

Notes

shipped production is serving it deploy ab54f53

opened this

I added the Chimney Sweep rules in chimney-sweep/roofs.js and a 12-test file, chimney-sweep/roofs.test.mjs. bun test chimney-sweep/roofs.test.mjs passes in 68–95 ms across two runs. The tests call the rules module directly and load no page, renderer or server. docs/VISION.md and scripts/gate.ts don't exist in this repo, so I read neither and ran no gate. bun x tsc --noEmit only prints its help text because there is no tsconfig, so the type check never ran.

What the rules do

  • Setup: start(seed) gives a 20 m stack with 4 flues, and the sweep at the bottom of flue 1. It also gives 60 puffs, each with a flue, a start time (one per second from 1.5 s) and an initial rise speed and acceleration. Randomness comes only from the seed.
  • Puff height: a puff's height is the closed form h = v0·τ + a·τ²/2, and a puff lasts 8 s.
  • Hits: they are tested on a fixed 0.01 s grid of absolute times, not at tick boundaries, so the result is the same however time is sliced. The tests check 10 ms, 50 ms, irregular and 20 s slices.
  • Pull: pull lifts the sweep 1 m, and further pulls are refused for 0.5 s.
  • Slide: the sweep holds still during that cooldown, then slides back at 1.5 m/s, never below the bottom.
  • Moving sideways: shift(-1 | 1) moves one flue and is refused at the outer walls.
  • Puff hit: a puff in the sweep's flue within 0.5 m of its height costs a life, once per puff, and knocks the sweep down 3 m.
  • Scoring: reaching the top scores 1000, plus 200 per life left, plus a time bonus of up to 500 that falls linearly to 0 at the 60 s limit. Losing all 3 lives or hitting the time limit ends the game with a loss line, and the win line reports the score.
  • Refusals: tick, pull and shift each refuse bad input or a finished game with { ok: false, state, why }, returning the same state.

I touched nothing outside chimney-sweep/. There is no page and no catalogue entry, as the issue asked. Every number above is an exported constant, so a later page can show its assumptions.

To try it: bun test chimney-sweep/roofs.test.mjs.

Closes #287

commented

I added the Chimney Sweep rules in chimney-sweep/roofs.js and a 12-test file, chimney-sweep/roofs.test.mjs. bun test chimney-sweep/roofs.test.mjs passes in 68–95 ms across two runs. The tests call the rules module directly and load no page, renderer or server. docs/VISION.md and scripts/gate.ts don't exist in this repo, so I read neither and ran no gate. bun x tsc --noEmit only prints its help text because there is no tsconfig, so the type check never ran.

What the rules do

  • Setup: start(seed) gives a 20 m stack with 4 flues, and the sweep at the bottom of flue 1. It also gives 60 puffs, each with a flue, a start time (one per second from 1.5 s) and an initial rise speed and acceleration. Randomness comes only from the seed.
  • Puff height: a puff's height is the closed form h = v0·τ + a·τ²/2, and a puff lasts 8 s.
  • Hits: they are tested on a fixed 0.01 s grid of absolute times, not at tick boundaries, so the result is the same however time is sliced. The tests check 10 ms, 50 ms, irregular and 20 s slices.
  • Pull: pull lifts the sweep 1 m, and further pulls are refused for 0.5 s.
  • Slide: the sweep holds still during that cooldown, then slides back at 1.5 m/s, never below the bottom.
  • Moving sideways: shift(-1 | 1) moves one flue and is refused at the outer walls.
  • Puff hit: a puff in the sweep's flue within 0.5 m of its height costs a life, once per puff, and knocks the sweep down 3 m.
  • Scoring: reaching the top scores 1000, plus 200 per life left, plus a time bonus of up to 500 that falls linearly to 0 at the 60 s limit. Losing all 3 lives or hitting the time limit ends the game with a loss line, and the win line reports the score.
  • Refusals: tick, pull and shift each refuse bad input or a finished game with { ok: false, state, why }, returning the same state.

I touched nothing outside chimney-sweep/. There is no page and no catalogue entry, as the issue asked. Every number above is an exported constant, so a later page can show its assumptions.

To try it: bun test chimney-sweep/roofs.test.mjs.

Approved

Rules-only pull, as the issue asked: plain data in/out, seeded puffs, closed-form puff height, hits tested on a fixed absolute grid so slicing does not matter, refusals return the same state with a reason. Tests cover each rule and run in well under a second. Two things I would do next: (1) the playable page and catalogue entry on top of these rules, with keyboard (arrows + pull key) and a 360px thumb layout, showing state.line in an aria-live region; (2) add a test for a hit landing exactly on a tick boundary and for pull() at exactly the time limit, to pin the 1e-9 tolerances.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs