Exercise 4:
Start by setting up a simple maze (unless your teacher has already set up a maze). The picture below shows a sample cardboard maze created by teachers at Longwood University’s Institute for Teaching through Technology and Innovative Practices (ITTIP) program.
To complete the maze, you will create a “wall following” robot. To follow a wall, your robot should repeat these three steps:
Move forward in a curved path (curving to the left or right) until an obstacle is detected.
Move straight back a short distance.
Rotate in the opposite direction (45° to 90°).
This is a basic algorithm for following a wall, but you have some work to do to turn this algorithm into a program that works well for your robot. You will need to adjust your motor power and movement times until your program works correctly. Try to make your robot complete the maze as quickly as possible!
Another way to solve a maze would be to write a program with a specific sequence of moves and turns. What are the advantages of the wall-following algorithm?
Extension 1: Can your robot start at the end of the maze and move through the maze to the start? Do you need to modify your program?
Extension 2: Could your program solve a new maze? How much could the current maze change before your program would no longer work? What changes can you make to your program to enable it to solve different mazes?