Blockly Maze Tasks
Example 1 - Using loops
When solving longer mazes, it is often best to look for areas of the maze that require the same block to be used again and again. In the maze shown below the robot has to go forward 7 times in a row, do some more stuff and then go forward 7 times in a row. We can use loops to speed up the code writing process.
Two types of loops are provided:
- A Repeat do loop: This is an infinite loop
- A Repeat 10 times loop: This repeats the instructions it encloses 10 times. (The 10 is editable.)
In the maze below, the number of blocks you are allowed to use is limited to 12, so we cannot solve this without using loops. Note how the Repeat do loop is not much use to us here!
Try to get the robot to the green square in this simple maze:
Maze Tutorial Start
Example 1 - Using loops
Example 2 - Using using if blocks