Skip to content

TrigScript 4, A0–A2: the lifted game checks the build, and tests run in it - #2

Closed
jeany55 wants to merge 7 commits into
mainfrom
v4-plan
Closed

jeany55 wants to merge 7 commits into
mainfrom
v4-plan

Conversation

@jeany55

@jeany55 jeany55 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

This starts TrigScript 4: the lifted 1.16.1 game (scm-sim) checks what TrigScript builds. A script's tests run in the game as well as in the simulator, and a run's memory accesses are checked against what Remastered allows, line by line. The plan, with an "As built" section for each slice, is docs/v4-plan.md.

A1: what a run touches, by line (Node only for now)

  • The trigger map. With the triggerMap setting, python/trigscript.py labels every trigger with the statement it came from, then logs where each one sits in the payload.
  • The allowlist. data/allowlist.json (191 entries) lists what Remastered lets through. It comes from Magenta's catalogue, three failures seen in the real game, and the traces of the 15 played probes.
  • The checker. compiler/allowlist.ts checks a run's trace against the allowlist, byte by byte under the mask, and names the address. scripts/game-check.mts builds, plays and reports by line.

A2: tests in the game

  • GameSim (compiler/gameSim.ts) gives a test the same sim as the simulator, driven through scm-sim's test handle:
    • Every read is the game's memory.
    • Units are placed, killed, removed, given and moved by the game's own actions, through a scratch location that is put back afterwards.
    • A typed line is chat command 0x5C, and keys and the mouse are the local machine's memory.
  • sim.program() reads a program's variables where the build says they are. With the variableMap setting the lowering logs each cell's address, and compiler/gameVariables.ts reads them by the simulator's lookup rules.
  • dist/gametest.js runs the compile's JavaScript again beside the game. The plugin never loads it; it hands the text to the host.
  • In the editor: Run all tests in the game in the Testing view and the palette. Each test gets a second mark for the game, ringed red when the game and the simulator disagree. Test Results gets an "in the game" row. The build's machine lines are kept out of Output.
  • Under Node: scripts/test-game.mts prints the game and simulator results side by side.

Simulator fix found by the game

  • Kill Unit, Kill Unit At Location, u.kill() and hit points written to 0 counted a death in the simulator. The game counts none of them, and the editor's trigger reference agrees.
  • Fixed (World.gone(…, fought)), and three tests were corrected to the game's rule.

Checked

  • probes/game-tests.ts and probes/game-program.ts pass in the game and the simulator.
  • In a built editor, served beside scm-sim's page: "In the game: 5 of 5 tests passed." about 10 s after the click, eudplib's one-time install included.
  • The plugin suite passes (611 tests).

Depends on: jeany55/scm-sim#19 deployed to /play/, and scm-js/plugin-scm-sim#13 released as 0.10.0. Without those the button says what's missing and does nothing else. The build-fixture scripts use scm-js/plugin-eudplib#1 for the log file.

After merging: cut a release (4.0.0 per the plan, or a minor if A1's Node-only tools shouldn't count as 4.0), then pin it in scm-js.

🤖 Generated with Claude Code

jeany55 and others added 7 commits October 15, 2026 23:35
The lifted game as the checker (A), the language (B), the game pushed (C).
A0 ran the same day: every probe plays headless in scm-sim's lifted game.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y line

- python/trigscript.py, with the triggerMap setting: every trigger tagged
  with the statement it was lowered from (or eudplib's function, or
  "eudplib"), and its place in the payload logged once laid out. Off by
  default; a build without it is unchanged.
- scripts/build-fixture.mts: TRIGGER_MAP=1 writes <map>.triggers.json, from
  eudplib's log read whole from a file.
- compiler/allowlist.ts: the allowlist's shape and checkTrace, byte by byte
  under each access's mask; findings by line, gravest first, said in words.
- data/allowlist.json from scripts/allowlist.mts: Magenta's catalogue, three
  failures seen in the game, and what the 15 played probes touched.
- scripts/game-check.mts: build, play in scm-sim's lifted game, check.
- docs/v4-plan.md: A1 as built.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Kill Unit, Kill Unit At Location, a unit's kill() and hit points brought
to 0 by damage() or a write all counted a death in the simulator. The
lifted game counts none of them: only a unit that dies in the game, shot
or killed by a spell, is a death (the editor's trigger reference, checked
in the game, says the same of Kill Unit). Found by the first tests run in
the lifted game. sim.kill() in a test stays a fight, and still counts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- compiler/gameSim.ts: GameSim, the world a test is handed in the game,
  over a GameHandle the host supplies (scm-sim's testGame); place, kill
  (counted as a fight by the game's own routine), remove, give and move
  through the game's trigger actions and a scratch location; keys and the
  mouse as the local machine's memory; a typed line as the chat command;
  every read from memory. readLocations: the map's locations once eudplib
  has put them right.
- compiler/testing.ts: TestWorldLike and a brand both worlds carry;
  TestRunOptions.makeWorld.
- compiler/gameTests.ts + dist/gametest.js: the compile's JavaScript
  (CompileResult.modules) run again beside the game, without TypeScript.
- scripts/test-game.mts: each test in the game and in the simulator, said
  twice; probes/game-tests.ts passes in both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run All Tests in the Game (Testing view and palette): the map built as Save
builds it, exported whole, handed with dist/gametest.js's text and the
compile's JavaScript to the scm-sim plugin's engine through its new test();
each test gets a second mark, "game", red where the two disagree, and the
Test Results panel says what the game found. vendor/scmSim.ts is the part
of the scm-sim contract TrigScript uses; it never imports the engine.
docs/v4-plan.md: A2 as built — a test is not a program, the traps met, the
simulator bug the first run found.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the editor

Run All Tests in the Game was driven end to end in a built editor (scm-js
main under /editor/, scm-sim's analysis page beside it, the local plugin
builds): 4 of 5 passed in the game, the fifth — sim.program(), which the
game cannot answer yet — shown as a disagreement. The game's mark now sits
next to the simulator's icon, where a narrow sidebar still shows it, ringed
when the two differ; the scm-sim plugin it needs is 0.9 (0.8.0 is out
without test()).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The lowering says where each program's variables are when the build asks it to (the
variableMap setting): the address of every cell once eudplib has placed the payload, in
TRIGSCRIPT-VARS / TRIGSCRIPT-PROGRAM lines of the build's log. compiler/gameVariables.ts reads
those lines and reads a program's variables out of the game's memory as the simulator's lookup
does, so GameSim answers sim.program(). Run All Tests in the Game and scripts/test-game.mts ask
for the map; Output leaves those lines out.

probes/game-program.ts passes in the game and the simulator; in a built editor all five tests
of the end-to-end run pass in the game. The scm-sim plugin's test() ships in 0.10 (0.9.0 went
out with the Replay view's zoom), and the message says so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jeany55

jeany55 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

Moved to #3: this work now lives on trigscript-4, which collects all of TrigScript 4 and merges into main when it's complete.

@jeany55 jeany55 closed this Oct 16, 2026
@jeany55
jeany55 deleted the v4-plan branch October 16, 2026 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant