Files
functional-programming-snake/scripts/fixtures
Lucas WintherandClaude Fable 5.2 5062838604 chore: keep the fixture generator scripts and the replay-sample bot
scripts/fixtures/ holds the scripts that produced the 2026-11-11
fixtures, with a README on running them safely into a copy. Run in
order they reproduce the content of every fixture they touch.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-11 12:13:03 +01:00
..

Fixture regeneration aids

The files in fixtures/ are the contract (see docs/contract.md). They were produced by the small scripts in this folder, which import the JavaScript reference solutions from js/solutions, compute the expected value of each case, and write the JSON. The scripts are kept so that the inputs chosen for each case are not lost and so that new cases can be added the same way. They are maintainer aids, not part of any check.

Before running one, read it. Each writes into fixtures/ unless the environment variable FIXTURES_OUT names another directory (with a trailing slash). The safe way to use them:

tmp=$(mktemp -d) && cp fixtures/*.json "$tmp/"
FIXTURES_OUT="$tmp/" node scripts/fixtures/m13-life.mjs
diff -r fixtures "$tmp"            # read the difference by hand before copying anything back

A changed expectation in an existing case is a contract change: decide it on purpose, port it to Scala and F#, and record it in the build log.

Script Writes Notes
audit-frame-pong-tick-cases.mjs m10-update (the frame-… cases), m04-tick (eating-the-last-free-cell-wins), m11-pong-update (restart and edge cases) Replaces cases by name inside existing files.
m12-violations.mjs m12-violations The base cases; overwrites the file. Run the queue cases after it.
add-queued-field.mjs every fixture that contains a game state One-off migration that added "queued": null. Idempotent.
m10-update-queue-cases.mjs m10-update (the 16 turn-queue cases) Replaces by name, appends at the end.
m12-violations-queue-cases.mjs m12-violations (the 3 queue cases) Replaces by name, appends at the end.
m10-session-and-golden.mjs m10-session-update, m10-session-view, m10-golden The golden cases replay the event lists in golden-events/ through play(main, …).
m10-viewer.mjs m10-viewer-update, m10-viewer-key, m10-viewer-view Overwrites the three files.
m13-life.mjs m13-life-step, -update, -key, -click, -view Overwrites the five files, one case per line. m13-life-update.json in the repo has the same content in the indented format.
replay-sample-bot.mjs [seed] replay-sample.json when a seed is given A greedy bot that plays the pure game. Without an argument it only lists seeds whose game has 150–400 actions and at least 5 apples. The shipped sample is seed 1.

Run in the order of the table (the first five build on each other), into a copy of the current fixtures, they reproduce the content of every file they touch. This was checked on 2026-11-11.

Fixtures from before 2026-11-11 (m00–m09, m10-input, m10-moves-every, m11-pong-key, m11-pong-view, and the original cases of the others) have no generator here; their scripts were not kept. Add cases to them with a small script in the same style.