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>
22 lines
1.1 KiB
Rust
22 lines
1.1 KiB
Rust
//! Conditions (Module 11): `X ON Z IS P` gives an X the property P only while it is on a Z.
|
|
//!
|
|
//! The parser reads a condition into the rule (`Rule::conditions`); the engine never
|
|
//! decides it there. A condition is evaluated for one object, against the board as
|
|
//! it is, every time a rule is about to be used: by `Level::has_property` (and so by
|
|
//! movement, the hazards and the win check), and by conversion. What a condition
|
|
//! word means is a `ConditionCheck` that content provides, registered by word, as
|
|
//! movement responses and hazards are. The engine knows only that a word with role
|
|
//! `Condition` may stand between the subjects and `IS`.
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use super::grid::ObjectId;
|
|
use super::level::Level;
|
|
|
|
/// Content's meaning for one condition word: does the condition, with these nouns
|
|
/// (in the order they are written), hold for object `id` on the board as it is now?
|
|
pub type ConditionCheck = fn(&Level, ObjectId, &[String]) -> bool;
|
|
|
|
/// Content's condition checks, by condition word: `{"ON": on}`.
|
|
pub type ConditionChecks = HashMap<String, ConditionCheck>;
|