Side Trips
The dog walks along a corridor between hedges. Here and there, the hedge on its left has a gap: a niche, one tile deep, with a bone in it. The niches are in different places on each map. The program from A Path with Bones won't help here: there's always a path ahead, so the dog would walk straight past the niches.
So far, each part of your If blocks held a single block. But an If can hold as many blocks as you like, and when its condition is true, it carries them all out, from top to bottom. Here, the If holds a whole little trip into the niche and back:
- Turn left, to face the niche.
- Move forward into it and pick up the bone.
- Turn around: two turns the same way.
- Move forward, back into the corridor.
- Turn to face the way on.
The last step is the easiest to forget. Which way does the dog face when it comes out of the niche, and which turn puts it back on its way? Put yourself in the dog's place, or turn the view.
The rest of the program is short. On every pass of the loop, the dog takes a step along the corridor and checks whether there's a niche on its left:
Repeat until at the goalMove forwardIfpath to the left- the trip into the niche and back
Go through the last pass in your head: the dog steps onto the goal, and the If asks once more. There's no niche next to the goal, so nothing happens, and the loop ends.
Instructions
- 1
Pick up all the bones on all the maps.
- 2
Walk to the goal.