Movement planned in full, then committed: a Planner builds a plan (moving and destroyed ids) by running content's movement responses (OPEN/SHUT, PUSH, STOP) for every step, rolling back failed branches. Edge of level blocks; YOU objects move furthest-ahead first; rules are reparsed once after movement. Harness: move/move_dir(Dir), posOf, kindsAt. Expansion Drop: PULL as one word plus one content response. Co-Authored-By: Claude Opus 5.5 <[email protected]>
33 lines
953 B
Rust
33 lines
953 B
Rust
// Module 8 Expansion Drop: PULL. The scenario is in expansion/README.md.
|
|
use engine::harness::*;
|
|
|
|
#[test]
|
|
fn test_08x_pull_follows() {
|
|
let mut b = new_baba(LevelDef {
|
|
width: 5,
|
|
height: 3,
|
|
..Default::default()
|
|
});
|
|
for (word, x) in [("BABA", 0), ("IS", 1), ("YOU", 2)] {
|
|
b.place(&format!("text:{word}"), x, 0);
|
|
}
|
|
for (word, x) in [("ROCK", 0), ("IS", 1), ("PULL", 2)] {
|
|
b.place(&format!("text:{word}"), x, 1);
|
|
}
|
|
let far_rock = b.place("rock", 0, 2);
|
|
let near_rock = b.place("rock", 1, 2);
|
|
let baba = b.place("baba", 2, 2);
|
|
|
|
b.move_dir(Dir::Right);
|
|
|
|
assert_eq!(b.pos_of(baba), Some((3, 2)));
|
|
assert_eq!(b.pos_of(near_rock), Some((2, 2)));
|
|
assert_eq!(b.pos_of(far_rock), Some((1, 2)));
|
|
|
|
b.move_dir(Dir::Left);
|
|
|
|
assert_eq!(b.pos_of(baba), Some((3, 2)));
|
|
assert_eq!(b.pos_of(near_rock), Some((2, 2)));
|
|
assert_eq!(b.pos_of(far_rock), Some((1, 2)));
|
|
}
|