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>
18 lines
2.4 KiB
Markdown
18 lines
2.4 KiB
Markdown
# Module 11 reference engine (Rust)
|
||
|
||
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/rust/README.md` describes everything else.
|
||
|
||
- `cards/` and `levels/` (at the crate root; not in this directory): staged by `tools/verify-references.mjs` as for Module 10 (`course/cards/`, `course/10-spellgrid/cards/` and `course/10-spellgrid/levels/`), so SpellGrid's tests run here too.
|
||
- Part II (`src/engine/puzzle/`):
|
||
- `word.rs`: a fourth role, `Role::Condition`.
|
||
- `parse.rs`: `Condition { word, nouns }` and `Rule::conditions`. `before_is` reads what stands before an `IS`: the subjects alone, or, when a condition word stands before the run of nouns next to `IS`, the subjects before that word with the condition (`noun_runs` reads one noun from each tile of a stack). `Display` writes `BABA ON KEY AND ROCK IS WIN`. `Rule::negates` and the new `Rule::same_conditions` pair rules only with the same conditions.
|
||
- `resolve.rs`: negation and the identity lock pair rules only when their conditions are the same.
|
||
- `condition.rs` (new): `ConditionCheck`, `fn(&Level, ObjectId, &[String]) -> bool`, and `ConditionChecks`, content's checks by word.
|
||
- `level.rs`: `Level::new` takes the condition checks and panics if a condition word has none. `applies_to(rule, id)` (the subject names the object and every condition holds for it now) is what `has_property` and 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.rs`): `SpellGrid::new` takes the condition checks; `rule_auras` skips a rule with a condition.
|
||
- `src/content/conditions.rs` (new): `on`, registered under `ON`. `words.json` adds `{ "name": "ON", "role": "condition" }`.
|
||
- `src/harness.rs`: `new_baba` and `new_spell_grid` pass `content::conditions()`. No new harness function: `rules()` and `active_rules()` print conditions.
|
||
- `src/cli.rs` and `src/bin/spellgrid.rs`: unchanged from Module 10. `tools/play-spellgrid.mjs` plays Module 10's; `tools/diff-tracks.mjs` uses this module's by default.
|
||
|
||
Run it with the module's tests: `node tools/verify-references.mjs 11` from the course repository.
|