feat: undo in Module 9 and stackAt from Module 8; Lesson 8 quote matches the reference
Baba.undo() restores the level before the last step or move (board snapshot: objects in age order with ids, the id counter, and won; rules recompiled). place clears the history. SpellGrid's undo throws/panics 'not supported'. stackAt / stack_at lists a tile's kinds oldest first, on Baba and SpellGrid. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
21fb40c6f5
commit
820b378929
27 files changed
+530
-30
No files matched your search
@@ -12,6 +12,6 @@ The course's own engine as of the end of Module 8. Part I's card engine is uncha
|
||||
- The rest of `src/engine/`: Part I, unchanged.
|
||||
- `src/content/movement.rs` (new) and `src/content/mod.rs`: the movement responses, in the order the engine runs them: `OPEN`/`SHUT`, `PUSH`, `STOP`. What a property does when something moves is content, not engine.
|
||||
- `src/content/words.json`: Module 8 adds `OPEN` and `SHUT`.
|
||||
- `src/harness.rs`: the adapter the course tests call. Module 8 adds `Baba::move_dir`, `Baba::pos_of`, `Baba::kinds_at`, and re-exports `Dir`.
|
||||
- `src/harness.rs`: the adapter the course tests call. Module 8 adds `Baba::move_dir`, `Baba::pos_of`, `Baba::kinds_at`, `Baba::stack_at`, and re-exports `Dir`.
|
||||
|
||||
Run it with the module's tests: `node tools/verify-references.mjs 08` from the course repository.
|
||||
@@ -306,6 +306,12 @@ impl Baba {
|
||||
kinds.sort();
|
||||
kinds
|
||||
}
|
||||
|
||||
/// The kinds on tile (x, y), as `kinds_at`, but oldest object first.
|
||||
pub fn stack_at(&self, x: i32, y: i32) -> Vec<String> {
|
||||
let board = self.level.board();
|
||||
board.at(x, y).map(|o| o.kind.to_string()).collect()
|
||||
}
|
||||
}
|
||||
|
||||
fn normalised(rules: &[puzzle::Rule]) -> Vec<String> {
|
||||
|
||||
Reference in new issue
Block a user