Files
systemic-game-design-course/course/06-parser/reference/ts
Lucas WintherandClaude Opus 5.5 85959ba5a0
CI / Tool tests and sync-check (push) Successful in 16s
CI / Verify references (all modules, Rust and TS) (push) Successful in 2m4s
CI / Verify Expansion Drop solutions (all modules, Rust and TS) (push) Successful in 2m1s
CI / Coupling audit on references (push) Successful in 5s
CI / Differential fuzzing of the Rust and TS references (300 seeds) (push) Successful in 53s
CI / Mutation check (tools/mutants.json against the highest TS reference) (push) Successful in 34s
CI / Verify the SpellGrid level proofs (solver) (push) Successful in 5m25s
CI / Site build (push) Successful in 15s
CI / Naive engine tests (Module 0) (push) Successful in 20s
fix: final review (engine errors end a Sequence cleanly; nesting guard labelled as the course's; Node 22.15; minor lesson and tool fixes)
I1: run-scenario and both SpellGrid CLIs check moves first and treat any other engine
error as fatal (same text in both tracks); trigger blocks close on error (try/finally,
catch_unwind in Rust); unknown summons rejected. I2, I3, M1-M7, T3, T9a-c, T10a-b.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 14:58:27 +01:00
..
2026-10-29 03:33:53 +01:00
2026-10-29 03:33:53 +01:00
2026-10-29 03:33:53 +01:00
2026-10-29 03:33:53 +01:00
2026-10-29 03:33:53 +01:00
2026-10-29 03:33:53 +01:00
2026-10-29 03:33:53 +01:00

Module 6 reference engine (TypeScript)

The course's own engine as of the end of Module 6, the first module of Part II. Part I's card engine is unchanged, and all of its tests still pass. Beside it, in src/engine/puzzle/, is a second engine for Baba Is You: a grid of objects and text, a lexer and a parser. Module 5's reference was the starting point, so a diff between the two shows what this module adds.

  • cards/ (at the package root; not in this directory): Part I's card data, a copy of course/cards/ staged by tools/verify-references.mjs. Part II doesn't read it.
  • src/engine/puzzle/: the Part II engine. It names no noun: the engine's own words are the operators IS, AND, NOT, the meta-noun TEXT and the property PUSH of the base rule TEXT IS PUSH.
    • grid.ts: the level format (LevelDef, course/schema/level.schema.json), object kinds ("<noun>" or "text:<WORD>") and the board: objects on tiles, several per tile allowed.
    • word.ts: the lexicon (every word the parser can read, with its role: noun, property or operator) and the lexer, which turns the text on the board into words by tile. Text whose word isn't in the lexicon spells nothing.
    • parse.ts: the parser. From every IS, in a row and in a column, it collects the AND-joined subjects before it and the AND-joined complements after it, and emits one rule per pair. Stacked words each count. Base rules come first.
    • level.ts: a level in play. Every change to the board recompiles the rules from scratch.
    • index.ts: the module's exports.
  • The rest of src/engine/: Part I, unchanged from Module 5 except for the export that adds puzzle.
  • src/content/words.json: the nouns and properties the parser knows, as data ({ "name", "role" }). src/content/index.ts reads it with a JSON import as words() (tsconfig.json gains resolveJsonModule so tsc accepts the import; Vitest needs nothing). A new word is a new entry here.
  • src/harness.ts: the adapter the course tests call. Module 6 adds newBaba, and place and rules on Baba. rules() sorts the rules' normalised strings and keeps each distinct rule once; the engine itself keeps a rule spelled twice twice.

Run it with the module's tests: node tools/verify-references.mjs 06 from the course repository.