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

Summary

In this lesson, you learned that:

  • The If … block carries out the blocks inside it only when its condition is true, and at most once. To decide on every tile, put it in a loop.
  • If … else chooses between two options: exactly one of its two parts is carried out, never both and never neither. In a loop, each pass carries out only one of them: a pass in which the dog turns doesn't move it.
  • The dog's senses are conditions: bone here, path ahead, path to the left and path to the right. Left and right are from the dog's point of view.
  • An If doesn't have to be inside a loop. Where the dog decides just once, as in the Which Way at the Corner? exercise, the If goes between other blocks, and the program goes on under it.
  • An If can hold many blocks, such as a whole trip into a niche and back. At the end of the trip, check which way the dog faces.
  • An If inside another If is a nested condition. The inner decision is made only when the outer one came out "no", so it goes into the else part.

Practice: the corridor with niches is back, but this time, some niches are empty. A dog that tries to pick up a bone in an empty niche stops with an error: "There's no bone here." Build the whole program again, from the start.

In the next lesson, Not, you'll learn to turn a condition around, so that the dog can, for example, walk on until it finds a bone.

Instructions

  1. 1

    Pick up all the bones on all the maps.

  2. 2

    Walk to the goal.

Back

9/9

  1. 1. The If Block
  2. 2. If, Else
  3. 3. Which Way at the Corner?
  4. 4. Quiz: One Part per Pass
  5. 5. An If Inside an If
  6. 6. A Path with Bones
  7. 7. Quiz: A Bug in a Nested If
  8. 8. Side Trips
  9. 9. Summary
Next

Try it yourself

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