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>
45 lines
1.6 KiB
Rust
45 lines
1.6 KiB
Rust
//! The turn (Module 9): one move of the player, as a fixed list of phases.
|
|
//!
|
|
//! The course's turn is a labelled simplification of the game's (see the lesson):
|
|
//! movement, parse, conversion, parse, hazards, win, and a last parse so that
|
|
//! the rules match the board when the turn ends. Each phase reads the rules from
|
|
//! the parse before it, so a rule that movement breaks is gone before hazards run.
|
|
//!
|
|
//! What a hazard property does (`SINK`, `HOT`/`MELT`, `DEFEAT`, ...) is a `Hazard`
|
|
//! that content provides, as with movement's responses. The engine runs them in
|
|
//! content's order and owns only the phases, `YOU`, `WIN` and float levels.
|
|
|
|
use super::grid::ObjectId;
|
|
use super::level::Level;
|
|
|
|
/// One phase of the turn.
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
pub enum Phase {
|
|
/// Every `YOU` object moves (Module 8), without the reparse.
|
|
Movement,
|
|
/// The rules are recompiled from the board.
|
|
Parse,
|
|
/// `X IS Y` conversions, and `X IS NOT X` deletions.
|
|
Conversion,
|
|
/// Content's hazards, in content's order.
|
|
Hazards,
|
|
/// A `YOU` object on a `WIN` one (or `WIN` itself) wins the level.
|
|
Win,
|
|
}
|
|
|
|
/// The turn, in order.
|
|
pub const TURN: [Phase; 7] = [
|
|
Phase::Movement,
|
|
Phase::Parse,
|
|
Phase::Conversion,
|
|
Phase::Parse,
|
|
Phase::Hazards,
|
|
Phase::Win,
|
|
Phase::Parse,
|
|
];
|
|
|
|
/// A hazard: content's rule for what destroys what at the end of a turn. It reads
|
|
/// the level and returns the objects to destroy; the engine destroys them all at
|
|
/// once, before the next hazard runs. An id may appear more than once.
|
|
pub type Hazard = fn(&Level) -> Vec<ObjectId>;
|