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

Migrated from github.com/amirmushichge/pixel-plays

Add Sheepdog: guide the flock through the gate and into the pen before the light goes #93

Merged opened this

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

Merged

Sheepdog is built and pushed to the branch. The sheepdog suite, the page tests, serve.test.mjs, shell.test.mjs, stats.test.mjs and the Sheepdog playtests all pass. I did not run a full bun test, as instructed.

Notes

shipped production is serving it deploy ab54f53

opened this

Sheepdog is built and pushed to the branch. The sheepdog suite, the page tests, serve.test.mjs, shell.test.mjs, stats.test.mjs and the Sheepdog playtests all pass. I did not run a full bun test, as instructed. My first push went up with one failing page test, because a command chain I wrote did not stop on the red result. The second push fixes it.

What changed

  • sheepdog/flock.js:

- The rules are plain data in and out and deterministic for a seed: sheep flee the dog inside a radius, flock together, wander when calm, and bolt the wrong way when pushed hard. - Only a sheep that came through the gate scores once it reaches the pen; one that went round scores nothing. - Each game is three fields with a new scatter and the gate moved. The round lasts 90 seconds, and 10 or more of 15 wins.

  • sheepdog/flock.test.mjs: I rewrote the drive test so a dog held behind the flock herds it through the gate and into the pen on all three fields. The old version stopped early because the field resets once all five are penned.
  • sheepdog/index.html:

- The scene is a 360x280 canvas at the fixed camera, with dry-stone walls, gate posts, a hurdle pen, hard shadows screen-right and a dog. - A crow on the wall and the grass are the only ambient motion, and both stop under prefers-reduced-motion. - The sun lowers and reddens as the clock runs out. - The HUD shows field, penned, time left, total and best. - Drag runs the dog; the arrow keys (or WASD) move it in screen directions. The aria-label says how to play, the rules popup is three lines, and the #mute button is there with no .mp3.

  • Wiring:

- The game is in GAMES in shell.js with the specified entry. - index.html has the matching <li>. - The README has the Games table row, the no-music list and the ambient-motion line. - serve.test.mjs has the /sheepdog/ and /sheepdog/flock.js check. - og/sheepdog.png and its share tags came from bun scripts/og.mjs, which also regenerated og/home.png.

  • Extra tests: sheepdog/page.test.mjs covers the HUD, the drag, the arrow keys and the mute button. rounds.mjs has a scripted round that herds by pointer. The scripted round wins, ending on "the flock is home · N of 15", while an untouched game ends on "dusk falls · 0 of 15, ten wins".

What I chose not to do

  • No music or tracks; sounds are small oscillator blips behind the mute button.
  • No target marker under the finger while dragging.
  • The ground is flat, so the hillside is only a lighter-to-darker grass gradient.
  • The repository has no scripts/gate.ts, scripts/fast.ts or scripts/design-lint.ts and no tsconfig, so I could not run those checks.

How to try it Run bun serve.mjs and open /sheepdog/. Drag to run the dog, or use the arrow keys. Get behind the flock and push it to the gate, then to the pen.

Closes #74

3 earlier comments · 1 event
commented

Sheepdog is built and pushed to the branch. The sheepdog suite, the page tests, serve.test.mjs, shell.test.mjs, stats.test.mjs and the Sheepdog playtests all pass. I did not run a full bun test, as instructed. My first push went up with one failing page test, because a command chain I wrote did not stop on the red result. The second push fixes it.

What changed

  • sheepdog/flock.js:

- The rules are plain data in and out and deterministic for a seed: sheep flee the dog inside a radius, flock together, wander when calm, and bolt the wrong way when pushed hard. - Only a sheep that came through the gate scores once it reaches the pen; one that went round scores nothing. - Each game is three fields with a new scatter and the gate moved. The round lasts 90 seconds, and 10 or more of 15 wins.

  • sheepdog/flock.test.mjs: I rewrote the drive test so a dog held behind the flock herds it through the gate and into the pen on all three fields. The old version stopped early because the field resets once all five are penned.
  • sheepdog/index.html:

- The scene is a 360x280 canvas at the fixed camera, with dry-stone walls, gate posts, a hurdle pen, hard shadows screen-right and a dog. - A crow on the wall and the grass are the only ambient motion, and both stop under prefers-reduced-motion. - The sun lowers and reddens as the clock runs out. - The HUD shows field, penned, time left, total and best. - Drag runs the dog; the arrow keys (or WASD) move it in screen directions. The aria-label says how to play, the rules popup is three lines, and the #mute button is there with no .mp3.

  • Wiring:

- The game is in GAMES in shell.js with the specified entry. - index.html has the matching <li>. - The README has the Games table row, the no-music list and the ambient-motion line. - serve.test.mjs has the /sheepdog/ and /sheepdog/flock.js check. - og/sheepdog.png and its share tags came from bun scripts/og.mjs, which also regenerated og/home.png.

  • Extra tests: sheepdog/page.test.mjs covers the HUD, the drag, the arrow keys and the mute button. rounds.mjs has a scripted round that herds by pointer. The scripted round wins, ending on "the flock is home · N of 15", while an untouched game ends on "dusk falls · 0 of 15, ten wins".

What I chose not to do

  • No music or tracks; sounds are small oscillator blips behind the mute button.
  • No target marker under the finger while dragging.
  • The ground is flat, so the hillside is only a lighter-to-darker grass gradient.
  • The repository has no scripts/gate.ts, scripts/fast.ts or scripts/design-lint.ts and no tsconfig, so I could not run those checks.

How to try it Run bun serve.mjs and open /sheepdog/. Drag to run the dog, or use the arrow keys. Get behind the flock and push it to the gate, then to the pen.

commented

I fixed the eight failures and pushed. The playtest file, the signal-box and soapbox-derby page tests, and the other two signal-box tests pass here. I didn't run the full suite; the forge runs that on this push.

What was wrong

  • Missing scripted rounds: Espresso Bar, Signal Box and Soapbox Derby had no scripted round in rounds.mjs. That broke the "every game has a scripted round" test and the three scripted-round tests.
  • Wrong state lookup: The Signal Box and Soapbox Derby page tests read the page's let state with vm.runInContext, which can't see it. They now use g.read, as the Sheepdog page test already does. That fixed the four page-test failures.

Scripted rounds added to rounds.mjs

  • Espresso Bar: pours while the cup is under the spout and lets go early enough for the stream's tail to land on the line. It runs all twenty cups and ends on "twenty cups poured · N".
  • Signal Box: pulls the right levers for two trains, then a wrong lever each turn until three trains are lost, ending on "N trains routed · the junction needs 8 to run on time". I couldn't script a win inside the 100 s limit: the game only ends on three lost trains, so a win means eight routed trains first, and the script never got there before the limit.
  • Soapbox Derby: steers to the middle of each next gap with the arrow keys and ends on "banner! N s".

What I didn't do: I didn't change any game code or the test harness.

Checks I skipped: The repo has no scripts/gate.ts or scripts/fast.ts, and I didn't run tsc.

To try it: run bun test playtest.test.mjs signal-box soapbox-derby/page.test.mjs. Run the playtest file in the background or with a long timeout, because it takes several minutes.

🤖 Generated with Claude Code

commented

I merged main into the branch, resolved the four conflicts and pushed. I ran the shell, serve, stats, limits, Firefly Jar and Sheepdog tests (94 pass, 0 fail) and the playtest rounds for Firefly Jar. I did not run the full suite; the forge runs that on this push.

Conflicts. Sheepdog and Firefly Jar both added themselves in the same places, so I kept both everywhere:

  • README.md: both table rows, and the sound-effects sentence now names "Sheepdog and Firefly Jar".
  • index.html and shell.js: both entries.
  • og/home.png: regenerated with bun scripts/og.mjs rather than picking one side, so the home card shows all the games.

Two fixes that came from the merge

  • Selection and touch-callout CSS: main's page test (from #89) requires every game page to carry it, and firefly-jar/index.html didn't, so I added the line there. This is a gap on main, not something from this branch.
  • Scripted round for Firefly Jar: main has a "every game has a scripted round" test and no round for it. I added one in rounds.mjs that shoos moths first, then taps glowing fireflies, and ends on "the night is survived · N in the jar".

I did not touch Firefly Jar's game logic or tests.

Changes requested — before the latest push

Sheepdog works in the preview: /sheepdog/, flock.js and og/sheepdog.png all answer 200. The rules are deterministic and tested, it is wired into shell.js, index.html and the README, and it ships no track. There is no server, identity or terminal surface in this repo, so the security items do not apply. It is a static game with no user text rendered as HTML. Remaining changes, all under Clean:

  1. Dead code in sheepdog/index.html. In wall(), t = course ? .74 : 0 is never used. In hurdles(), the dir parameter of run(a, b, dir) is never read, so drop it and the 0/1 arguments. In groundColor(x, y, ix, iy, i), x and y are unused.
  2. Dead code in sheepdog/flock.test.mjs. expect(GATE_HALF).toBeGreaterThan(0) at the end of the dog-movement test asserts nothing about that test and exists only to use an import. Remove it and the import. In the field-sequence test, for (const n of [1, 2]) has an unused n.
  3. Duplicate rule. Both firefly-jar/index.html and sheepdog/index.html add a second html, body { ... } rule beside the existing html, body { height... }. Merge the declarations into the existing rule.
  4. Scope. The rounds.mjs entries for Espresso Bar, Signal Box and Soapbox Derby, and the signal-box and soapbox-derby page test edits, are not Sheepdog. They are fixes for main's tests, so name them plainly in the pull description as separate from the game.
commented

Sheepdog is a 90-second dusk game over three hillside fields. You steer the dog by dragging it or with the arrow keys, and the sheep flee it, flock together when calm, and bolt if pushed too hard. Each field has a gate and a pen. The rules are in sheepdog/flock.js with tests beside them. It is added to the home page, shell.js, the README and the OG cards, and it ships no track. I've addressed @sentinel's four points and pushed. I ran the Sheepdog, Firefly Jar and serve tests (80 pass) after the cleanup; scripts/design-lint.ts doesn't exist in this repo, so I couldn't run it.

Cleanup from review

  • sheepdog/index.html: I removed the unused t in wall(), the unused dir parameter and its 0/1 arguments in hurdles(), and the unused x and y in groundColor.
  • sheepdog/flock.test.mjs: I removed the GATE_HALF assertion and its import, and replaced the unused n in the field-sequence loop with let k.
  • Duplicate html, body rule: I merged the selection and touch-callout declarations into the existing rule in sheepdog/index.html and in firefly-jar/index.html. The firefly-jar/index.html line was mine, from the merge.

Separate from the game. These came from keeping main's tests green and are not Sheepdog:

  • rounds.mjs: scripted rounds for Espresso Bar, Signal Box and Soapbox Derby. They were missing, so the "every game has a scripted round" test failed. The Signal Box script ends on a loss, because a win takes about 8 correct trains, which would exceed the 100 s limit.
  • Page tests: the Signal Box and Soapbox Derby page tests now use g.read, because they read the page's let state with vm.runInContext, which can't see it.
  • Firefly Jar: a scripted round, plus the selection and touch-callout CSS that main's page test (from #89) now requires and Firefly Jar lacked. The merge itself kept both games in the README, index.html, shell.js and a regenerated og/home.png.

I didn't change any game logic outside Sheepdog.

🤖 Generated with Claude Code

Approved

Approved. Sheepdog does what the issue asks. It is wired into shell.js, index.html, the README and the OG cards, ships no track, and has a mute button. It has rules tests, page tests, a scripted round and a serve test. Drag and arrow keys both run the dog. I read the diff and the source. I did not fetch the preview.

Two things I would do next:

  1. The #status live region (role=status, aria-live=polite) is rewritten by update() with N of 5 in the pen · M on the run. The on the run count changes many times a second while sheep move, so a screen reader will chatter. Keep the live region for the event notes (penned, bolted, field change, game over) and move the running count into a non-live element, or announce it only when the pen count changes.
  2. On a 360px phone the dog runs to the finger, so the thumb covers it and the sheep next to it. Offset the target a few units above the touch point, or draw a small marker. Also, canvas { outline: none } leaves keyboard focus invisible. Add a :focus-visible ring. The muted grey (#8b877f on white) is about 3.5:1 contrast for the 13px HUD text. Darken it a little.

Scope note: the rounds.mjs entries for Espresso Bar, Signal Box and Soapbox Derby, the two page-test edits and the Firefly Jar CSS are not Sheepdog. They keep main green, and the pull description should say so, as sentinel asked.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs