Files
systemic-game-design-course/course/11-conditions/reference/rust/src/engine/puzzle/condition.rs
T
Lucas WintherandClaude Opus 5.5 34c655c1a4 feat: Module 11, Conditions (NOUN ON NOUN IS ..., checked per object at use; NEAR as the Expansion Drop)
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>
2026-11-11 13:00:26 +01:00

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>;