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

Migrated from github.com/amirmushichge/pixel-plays

games need to have a much higher playability standard. tests that actually pl… #49

Merged opened this in answer to

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

Merged

Every game folder is now booted for real and played by a seeded stand-in for a person, and the new playtests pass on all 19 games. The issue had no body, so I read "tests that actually play" as booting the real page and driving the canvas with taps, drags, holds and keys.

Notes

shipped production is serving it deploy ab54f53

opened this

Every game folder is now booted for real and played by a seeded stand-in for a person, and the new playtests pass on all 19 games. The issue had no body, so I read "tests that actually play" as booting the real page and driving the canvas with taps, drags, holds and keys.

What changed

  • playtest.mjs runs a game's actual page in a vm: its inline scripts, shell.js and engine.js, with a small DOM stand-in. It gives tests seeded randomness, a fake clock and canvas input (tap, hold, drag, key press). It also reports what the player would see: the page text, a hash of the picture and a count of distinct colours.
  • playtest.test.mjs finds every game folder itself, so a new game is covered with no edit. Per game it checks that:

- the page boots with no script errors, paints more than 40 colours and shows some text; - 40 random gestures (taps, holds, drags, key presses) throw nothing and the picture keeps changing; - 10 seconds untouched produce no errors; - the keyboard alone makes a played copy of the game part ways with an untouched copy started from the same seed, in picture or in text.

  • The README has a short "Playtests" section. No dependency was added.

Not done

  • The runs are short: 40 gestures, 10 idle seconds and 20 key presses per game. Longer runs took about five minutes for the file, and Harbour Crane and Laundry render slowly. The file now takes about 2m15s locally and its default timeout is 120 s, so it still costs the forge's check a couple of minutes.
  • It checks that games respond and stay error-free. It does not check that a game can be won or lost, so per-game win and lose scripts would be the next step.
  • tsc was not run, because the repository has no TypeScript.

Try it: bun test playtest.test.mjs. To play one game by hand, import boot('orchard') from playtest.mjs and call .tap(), .drag() or .press().

🤖 Generated with Claude Code

Closes #42

1 earlier comment · 1 event
commented

Every game folder is now booted for real and played by a seeded stand-in for a person, and the new playtests pass on all 19 games. The issue had no body, so I read "tests that actually play" as booting the real page and driving the canvas with taps, drags, holds and keys.

What changed

  • playtest.mjs runs a game's actual page in a vm: its inline scripts, shell.js and engine.js, with a small DOM stand-in. It gives tests seeded randomness, a fake clock and canvas input (tap, hold, drag, key press). It also reports what the player would see: the page text, a hash of the picture and a count of distinct colours.
  • playtest.test.mjs finds every game folder itself, so a new game is covered with no edit. Per game it checks that:

- the page boots with no script errors, paints more than 40 colours and shows some text; - 40 random gestures (taps, holds, drags, key presses) throw nothing and the picture keeps changing; - 10 seconds untouched produce no errors; - the keyboard alone makes a played copy of the game part ways with an untouched copy started from the same seed, in picture or in text.

  • The README has a short "Playtests" section. No dependency was added.

Not done

  • The runs are short: 40 gestures, 10 idle seconds and 20 key presses per game. Longer runs took about five minutes for the file, and Harbour Crane and Laundry render slowly. The file now takes about 2m15s locally and its default timeout is 120 s, so it still costs the forge's check a couple of minutes.
  • It checks that games respond and stay error-free. It does not check that a game can be won or lost, so per-game win and lose scripts would be the next step.
  • tsc was not run, because the repository has no TypeScript.

Try it: bun test playtest.test.mjs. To play one game by hand, import boot('orchard') from playtest.mjs and call .tap(), .drag() or .press().

🤖 Generated with Claude Code

Changes requested — before the latest push

The harness is a good base: it adds no dependency, boots the real page, uses a seeded clock and picks up new games by itself. But neither play test can fail when a game ignores the player, so the pull does not yet give the issue's "tests that actually play". I checked this by rebuilding the two files from this diff in a scratch copy:

  1. Keyboard test (fix this first). I replaced played.keyDown/keyUp with no-ops, so no key ever reaches the game. Orchard, Pottery Wheel and Kite Hill still "part ways" at step 1. The cause is frame rounding. press(k, hold) + run(.3) advances round(hold*25)+1+8 frames, while idle.run(hold+.35) advances round(hold*25+8.75). Whenever frac(hold*25) is in [0.5, 0.75), the played copy runs one extra frame and any animated picture differs. Fix: drive both copies by a whole number of frames (for example run takes frames, or an api.frames counter that the test asserts equal before comparing), then compare.
  2. Pointer test. I made canvas.fire a no-op, so no pointer or key input arrives, and ran the 40-gesture test on all 19 games. Every game still showed 26–41 distinct pictures, well past the > 15 bar, because idle animation (snow, water, clouds) alone meets it. Compare against an idle twin advanced by the same frame count, as in point 1, so the test fails when input is disconnected.
  3. What "playability" means here. As written, the four tests only check that a game boots, animates and does not throw. For the issue's standard, each game needs at least one scripted run that reaches a game outcome: a deliberate input that changes the score or HUD text, and a round that ends (for example a small per-game play script in the test table: where to tap or drag, and what the HUD must then say). The pull body names win/lose scripts as "next step". They are the core of the issue, so land at least "input moves the score" per game here, or open a linked issue for the rest and say so in the pull.
  4. drag takes no game time. Each step calls run(seconds/steps) with seconds/steps = 1/60, and Math.round(25/60) = 0. Every move of a drag is delivered with no frame between them, so a game that samples the pointer per frame sees a teleport, not a drag.
  5. Small items: words.size > 0 cannot fail, because the set starts with one entry. Either assert the HUD text changes or drop that line. bun:test is imported twice (lines 1 and 4). readdirSync('.') depends on the working directory, while playtest.mjs resolves from import.meta.url; use import.meta.dir so bun test from another directory still finds the games.
  6. Cost. The file takes about 2m15s, with a 120 s per-test timeout, and it runs on every check. Once points 1 and 2 make the tests meaningful, see whether fewer gestures per game still catch a disconnected input, and state the run time in the README section.

Preview: / and /orchard/ answer 200. Nothing at runtime changed, and there is no new security surface.

commented

The playtests now fail when a game ignores the player. They still don't play a round through to a win or a loss. All 77 tests pass in about 1m40s. Only playtest.mjs, playtest.test.mjs and the README section changed, and nothing at runtime did.

Review points addressed

  • Frame rounding (1, 2): time now advances in whole frames, and api.frames counts them. The pointer and keyboard tests run a played copy against an untouched twin of the same seed. They advance the twin to the same frame, assert the counts match, then compare picture and HUD text.
  • Date was not seeded: orchard and window-washer seed their rounds from Date.now(), so two copies of the same game diverged by wall-clock time. Without this fix, the orchard pointer and keyboard tests passed even with input disabled. The vm's Date now follows the fake clock.
  • Checked by disconnecting input: with canvas.fire made a no-op, the pointer and keyboard tests fail for orchard, kite-hill, pottery-wheel and window-washer. I did not run that check on the other 15 games.
  • Drag (4): a drag now sends one pointer move per frame, so the game sees a moving pointer.
  • Small items (5): the pointer test now fails unless the HUD text differs from the idle twin, replacing the words.size > 0 line. The duplicate import is gone, and the games are found through import.meta.dir.
  • Cost (6): the 10-second idle test is now 4 seconds, and the pointer test stops as soon as it has seen both a picture and a HUD difference (at most 40 gestures). The README states the run time.

Not done

  • Per-game win/lose scripts (3): I did not write scripts that finish a round and check the final HUD text. "Input changes the HUD text" is proven for every game, but "a round ends with the right outcome" is not. This needs a script per game and is too large for this pull. I did not open a linked issue. The README lists it as not yet covered.

To try

  • Run bun test playtest.test.mjs.

🤖 Generated with Claude Code

Approved

The play tests now fail when a game ignores the player. I confirmed it at this head (8e5d8dd): I rebuilt playtest.mjs and playtest.test.mjs from the diff on top of current main (22 games, including campfire, beekeeper and bread-oven) and ran it twice.

  • As shipped: 89 pass, 0 fail, 113 s.
  • With Element.fire made a no-op, so no pointer or key input reaches any game: 44 fail. That is both the pointer test and the keyboard test for every one of the 22 games. The boot and idle tests still pass, as they should.

Earlier asks:

  1. Keyboard frame rounding: met. Time advances in whole frames, api.frames counts them, and sync() asserts both twins are on the same frame before comparing. The vm's Date following the fake clock was the hidden half of this, and it is a good catch.
  2. Pointer test vs idle animation: met. The test now compares against an idle twin with the same seed and frame, and the disconnected run above fails it for every game.
  3. Playability standard: met at the minimum I asked for. The pointer test requires the HUD text to differ from the idle twin, so "input moves the score/HUD" is now proven per game. Win/lose scripts were not opened as an issue, so I opened #62 for them. The README's "Not yet covered" line points at the same gap.
  4. Drag takes game time: met. There is one move per frame with step(1) between moves.
  5. Small items: met. words.size is gone, the duplicate import is gone, and the games are found through import.meta.dir.
  6. Cost: met. The README states the run time, and the pointer loop exits early once both differences are seen.

Preview: / and /orchard/ answer 200. Nothing changes at runtime, and there is no new request path, input or dependency.

Non-blocking: the file is about 1m50s of a bun test check that otherwise takes seconds, and it grows with every game. If the check gets tight, the idle test could share its boot with the first test (run 2 s, assert, then run 2 s more). Non-blocking: playtest.mjs and playtest.test.mjs sit in the web root, so serve.mjs will serve them, like the existing limits.mjs and *.test.mjs. This was already true before this pull and nothing secret is in them, but a tests/ folder outside the static root would be tidier for all of them.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs