Information about cookies on this page

Our website uses cookies to ensure the functionality of the website, to collect and analyze information about the performance and usage of the website. Privacy Policy

  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in
  
  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in

The Not Block

On each map, a bone lies somewhere on the path, and the path goes on past it. Right where the bone lies, a side path leads off to the left, to the goal. The dog has to walk to the bone, stop on it and pick it up, and then go down the side path. The bone is in a different place on each map, so no number of steps fits them all. And Repeat while path ahead would take the dog past the bone, to the end of the path.

The dog should walk as long as there's no bone under it. That's what the new not block is for. It's hexagonal like the senses, and it has a hexagonal slot of its own, for another condition. It turns that condition's answer around: not bone here is true where there's no bone, and false where there is one. Turning a condition around like this is called negation.

Put bone here into not, and not into the slot of Repeat while:

  • Repeat while not bone here
    • Move forward

Before every pass, the dog checks the condition: is it true that there's no bone here? While it is, the dog takes a step. As soon as it stands on the bone, the condition is false, the loop ends, and the program goes on with the blocks under the loop. So you can read the loop as "walk until there's a bone". Like any condition, not fits into every hexagonal slot, so it works in an If too. This time, though, there's no If among the blocks: a loop is enough.

You've been using such a loop for a while. Repeat until at the goal repeats its blocks while the dog is not at the goal. Python, JavaScript and many other programming languages have no Repeat until loop, only Repeat while, so that's how a programmer writes it there: repeat while not at the goal.

Instructions

  1. 1

    On all three maps, walk the dog to the bone with Repeat while not bone here, and pick the bone up.

  2. 2

    Then turn left and walk down the side path to the goal.

Back

1/7

  1. 1. The Not Block
  2. 2. Turn Until the Path Is Ahead
  3. 3. Quiz: Repeat While Not
  4. 4. Bones Mark the Way
  5. 5. Take the First Right
  6. 6. Quiz: A Bug with Not
  7. 7. Summary
Next

Try it yourself

Do this exercise right here in your browser. No account needed.