A Path with Bones
Put together everything you know: the dog has to walk along a winding path to the goal and pick up all the bones on the way. Some of them lie on straight sections, others right at a turn.
On every pass through the loop, the dog now does two things, one after the other:
- It checks whether there's a bone under it, and if there is, it picks it up.
- It decides where to go next, just as in the last exercise.
Both parts go in the loop, one under the other. The first is a separate If block without an else part: when there's no bone, the dog does nothing and goes straight on to the second part.
A big program is easiest to build in parts. You can first build the loop that gets the dog to the goal, try it out, and only then add picking up the bones.
Instructions
Pick up all the bones on all the maps.
Walk to the goal.
Start programming for free
4/4