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
Check · Review · Land · Live done — Landed and live in production.
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.
shipped production is serving it deploy ab54f53
1 earlier comment · 1 event
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.mjsruns a game's actual page in avm: its inline scripts,shell.jsandengine.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.mjsfinds 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.
tscwas 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
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:
- Keyboard test (fix this first). I replaced
played.keyDown/keyUpwith 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)advancesround(hold*25)+1+8frames, whileidle.run(hold+.35)advancesround(hold*25+8.75). Wheneverfrac(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 exampleruntakes frames, or anapi.framescounter that the test asserts equal before comparing), then compare. - Pointer test. I made
canvas.firea 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> 15bar, 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. - 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
playscript 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. dragtakes no game time. Each step callsrun(seconds/steps)withseconds/steps = 1/60, andMath.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.- Small items:
words.size > 0cannot fail, because the set starts with one entry. Either assert the HUD text changes or drop that line.bun:testis imported twice (lines 1 and 4).readdirSync('.')depends on the working directory, whileplaytest.mjsresolves fromimport.meta.url; useimport.meta.dirsobun testfrom another directory still finds the games. - 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.
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.framescounts 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:
orchardandwindow-washerseed their rounds fromDate.now(), so two copies of the same game diverged by wall-clock time. Without this fix, theorchardpointer and keyboard tests passed even with input disabled. The vm'sDatenow follows the fake clock. - Checked by disconnecting input: with
canvas.firemade a no-op, the pointer and keyboard tests fail fororchard,kite-hill,pottery-wheelandwindow-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 > 0line. The duplicate import is gone, and the games are found throughimport.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
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.firemade 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:
- Keyboard frame rounding: met. Time advances in whole frames,
api.framescounts them, andsync()asserts both twins are on the same frame before comparing. The vm'sDatefollowing the fake clock was the hidden half of this, and it is a good catch. - 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.
- 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.
- Drag takes game time: met. There is one move per frame with
step(1)between moves. - Small items: met.
words.sizeis gone, the duplicate import is gone, and the games are found throughimport.meta.dir. - 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.
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.mjsruns a game's actual page in avm: its inline scripts,shell.jsandengine.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.mjsfinds 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.
Not done
tscwas not run, because the repository has no TypeScript.Try it:
bun test playtest.test.mjs. To play one game by hand, importboot('orchard')fromplaytest.mjsand call.tap(),.drag()or.press().🤖 Generated with Claude Code
Closes #42