The apple that shouldn't have been there

A test asserting that hearts are growth-neutral failed on CI, intermittently, on a PR that never touched the file it failed in.

The screenshot.ts split passed every check locally and then failed on CI, on a test in a file that split had never touched: does not grow the snake, in the suite covering PvP’s lives system. Running it again passed. git log on the failing file confirmed it hadn’t changed since long before the PR under test, which meant the bug was already sitting there, just rare enough to have never come up before.

The test’s config never set a seed, so whenever the engine needed one it fell back to the current time, and the very first apple of each run landed somewhere different every time the test suite ran. The “eating a heart” case walks the snake three cells to the right to reach a heart placed just past its head. Almost always, nothing else sat on that path. Just often enough, the unseeded apple did, and the snake grew from eating it, an apple the test never meant to be there, on a test whose entire point is that hearts, unlike apples, never grow anything.

const PVP_CONFIG: DuelGameConfig = { ...DEFAULT_DUEL_CONFIG, livesEnabled: true, seed: 42 };

One added field, matching the seed every other engine test file in the suite already sets for exactly this reason. Run five times in a row afterward, the test passed all five, where before it had been a coin flip nobody had happened to lose until that particular CI run.