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:
Try this out in a new window ...
Maze Tutorial Start
Example 1 - Using loops
Example 2 - Using using if blocks
Did you know the UK Bebras Challenge is run by the Raspberry Pi Foundation? Discover free teaching resources, tools, and expert support for computing education at raspberrypi.org.