- :-

Topics Covered

  • Switch in Loop
  • Lesson Links

    Check Your Understanding:
    1. 1. What happens when you place a Switch inside a Loop?
    2. The robot runs in a circle until told to stop
      The robot makes a decision once, then repeats the result many times
      The robot makes a decision many times, taking whatever action is appropriate each time
      You cannot place a Switch inside a Loop
    3. 2. When a Switch is placed inside a Loop…
    4. Both the Switch and Loop operate normally, but the arrangement is useful
      The software interprets the Switch+Loop structure as a special construct
    Try It!
    Try it! 1

    Maze Runner

    The simple behavior you wrote in the video can be used as a very simple maze solver!

    Build a maze for the robot, made up of square floor tiles.

    If you don't have floor tiles, use 30 cm squares.
    Adjust your Forward movement to go one tile per movement, rather than 3 rotations.
    What happens?
    The robot will perform its move-or-turn behavior in each tile, eventually solving many simple maze configurations!
    Mini Challenge

    Mini Challenge 1: Smarter decisions challenge

    Enhance your program by adding the following features:
    1. Audio Feedback
      • Make the robot say, "Forward" any time it decides to move forward
      • Make the robot say, "Right" any time it decides to turn right
    2. Limited Duration
      • The robot may get stuck. Make the program end after it has performed 10 moves in total.

    Audio Hint. You can find both the “Forward” and “Right” sound files under the “Information” folder in the Play Sound Block

    Limited Duration Hint. You need to limit the behavior so that it only runs 10 times. Which part of the program controls the number of times the behavior repeats?

    + hint