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]>
2.6 KiB
2.6 KiB
Module 8 Expansion Drop: PULL
The lesson's Expansion Drop beat explains the task. This file holds the scenario, the test locations and the check.
- Word: PULL, a property. From the Baba Is You Wiki's PULL page (recorded in
docs/research/baba-is-you.md§5): "PULL is a Property that makes an object pullable by any moving object. PULL also makes the object "solid" for collision checks like STOP does.", and "If something directly adjacent from a PULL object moves away from it, the PULL object will try to move in the same direction." - Tests:
tests/rust/test_08x.rsandtests/ts/test_08x.test.ts. Copy the one for your track into your workspace'stests/. - Reference answer, one change in data and one in content code:
solution/words.json, one file for both tracks: the Module 8 reference'ssrc/content/words.jsonwith one entry added,{ "name": "PULL", "role": "property" }.solution/rust/src/content/movement.rsandsolution/ts/src/content/movement.ts: the Module 8 reference's movement responses with one response added,pull, listed afterpush.- Nothing under
src/engine/changes, and neither does the harness. PULL is a new behaviour, so it is new code, but it is a response the engine's planner runs like any other: the planner already lets a response look at any tile and ask for any object to move.
- Check: commit your workspace before you start, then run
node tools/expansion-check.mjs <your-workspace> <that-commit>from the course repository. It fails if any file undersrc/engine/changed.
The reference lets a PULL object that can't follow stay behind without stopping the mover. The PULL page doesn't say what happens then, and this test doesn't check it.
Scenario
test_08x_pull_follows
- Setup:
newBabawith an empty level 5 wide and 3 high. PlaceBABA (0,0) IS (1,0) YOU (2,0)andROCK (0,1) IS (1,1) PULL (2,1). Place an objectrockat (0,2) (the far rock), an objectrockat (1,2) (the near rock) and an objectbabaat (2,2). - Action 1:
move("right"). - Assertions 1:
posOf(baba)is (3,2), the near rock is at (2,2) and the far rock at (1,2). Baba moved away from the near rock, so it followed; the near rock moved away from the far rock, so that one followed too. - Action 2:
move("left"). - Assertions 2: nothing moved: Baba is still at (3,2), the near rock at (2,2) and the far rock at (1,2). A PULL object is solid: Baba can't step onto it, and PULL doesn't push.
Before the drop the lexicon doesn't know PULL, so ROCK IS PULL spells nothing: Baba walks away from the rocks, and in the second move walks back onto the near rock's tile.