Bones Mark the Way
The dog is in a park where paths cross everywhere. At every crossroads, there's a path ahead, to the left and to the right, so the senses that look for paths can't tell the dog where to turn. They aren't among the blocks this time. Instead, the owner has marked the way with bones: at the first bone, the dog turns left, and at the second, right. Then it walks on to the goal. The bones are in different places on each map, but the order is always the same: first left, then right.
Would an If inside Repeat until at the goal do it? On every tile: if there's a bone here, pick it up and turn left. But that If would turn the dog the same way at every bone, left at the first and left at the second too. It can't tell the two bones apart. So there's no If among the blocks either.
Instead, split the walk into parts, one loop for each, one under another:
Repeat whilenotbone herewithMove forwardinside takes the dog to the first bone. Pick it up and turn left.- The same loop again takes it to the second bone. Pick it up and turn right.
Repeat until at the goalwithMove forwardinside takes it to the goal.
Each loop ends where its part of the walk ends, and the next one goes on from there. The dog doesn't need to know which bone it's at: the order of the loops in the program tells it.
Instructions
- 1
On all three maps, walk to the first bone, pick it up and turn left, then walk to the second bone and pick it up too.
- 2
Turn right and walk to the goal.