Summary
In this lesson, you learned that:
- The
notblock turns a condition around:notbone hereis true where there's no bone, and false where there is one. This is called negation.notfits into every hexagonal slot, of a loop or of anIf, and it counts as a block. Repeat whilenot… repeats its blocks until the condition insidenotbecomes true. WithMove forwardinside, it walks the dog until it finds something: the next bone (notbone here) or the first opening on its right (notpath to the right). With a turn inside,Repeat whilenotpath aheadturns the dog until it faces the path.Repeat until at the goalis such a loop too: it repeats its blocks while the dog is not at the goal. That's how a programmer writes it in Python or JavaScript.- Loops one under another split a walk into parts. Each loop ends where its part ends, and the next one goes on from there. That's how the dog told the first bone from the second.
Repeat whilechecks its condition before every pass, the first one too. When the condition is false from the start, the loop makes no pass at all.- An
Ifin a loop asks again on every pass. When the dog should stop at the first of several places, use a loop withnot. - A missing or extra
notmakes a loop do the opposite of what it should. The program may stop only at a later block, so look for the mistake above it too.
Time to practice it all together. The dog starts in a dead end again, and a bone lies on the path out. Where the bone lies, a side path leads off to the right, to the goal.
In the next lesson, Checkpoint: The Obstacle Course, you'll put everything you've learned so far together in a small project: the dog runs an obstacle course at a dog show.
Instructions
- 1
On all three maps, get the dog out of the dead end, walk to the bone and pick it up.
- 2
Then turn right and walk to the goal.
- 3
Use at most 13 blocks.