Adds course/11-conditions: lesson, scenarios, nine test_11 tests in both tracks, the cumulative reference (Module 10's plus conditions) and the NEAR drop. The engine learns a condition role, rules carry conditions, and Level.hasProperty and conversion evaluate content's condition checks against the board whenever a rule is used. Resolution pairs only rules with the same conditions. Catalog, harness contract, research notes and the diff-tracks generator follow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2.4 KiB
2.4 KiB
Module 11 reference engine (TypeScript)
The course's own engine as of the end of Module 11: Module 10's engine (Part I's card engine and Part II's grid engine, joined by SpellGrid), with conditions in Part II. Every test from Modules 1–10 still passes. Module 10's reference was the starting point, so a diff between the two shows what this module adds. course/10-spellgrid/reference/ts/README.md describes everything else.
cards/andlevels/(at the package root; not in this directory): staged bytools/verify-references.mjsas for Module 10 (course/cards/,course/10-spellgrid/cards/andcourse/10-spellgrid/levels/), so SpellGrid's tests run here too.- Part II (
src/engine/puzzle/):word.ts: a fourth role,"condition".parse.ts:Condition { word, nouns }andRule.conditions.beforeIsreads what stands before anIS: the subjects alone, or, when a condition word stands before the run of nouns next toIS, the subjects before that word with the condition (nounRunsreads one noun from each tile of a stack).ruleTextwritesBABA ON KEY AND ROCK IS WIN.negatesand the newsameConditionspair rules only with the same conditions.resolve.ts: negation and the identity lock pair rules only when their conditions are the same.condition.ts(new):ConditionCheck,(level, id, nouns) => boolean, andConditionChecks, content's checks by word.level.ts: the constructor takes the condition checks and throws if a condition word has none.appliesTo(rule, id)(the subject names the object and every condition holds for it now) is whathasPropertyand conversion use, so every question about an object evaluates its conditions at that moment.names(word, id)is public, for content's checks.
- Part III (
src/engine/spellgrid.ts):SpellGrid's constructor takes the condition checks;ruleAurasskips a rule with a condition. src/content/conditions.ts(new):on, registered underON.words.jsonadds{ "name": "ON", "role": "condition" }.src/harness.ts:newBabaandnewSpellGridpassconditions(). No new harness function:rules()andactiveRules()print conditions.src/cli.ts: unchanged from Module 10.tools/play-spellgrid.mjsplays Module 10's;tools/diff-tracks.mjsuses this module's by default.
Run it with the module's tests: node tools/verify-references.mjs 11 from the course repository.