Blockly Maze Tasks
Example 2 - Using if blocks
The infinite or Repeat do loop block comes into its own when it is combined with some decision blocks.
Now we can wrap our code in a Repeat do block and ask the robot to make decisions: We can send the robot forwards unless it discovers it can turn left. If it can turn left, it should do and then go forward again.
See if you can use this algorithm to get the robot to the green square in the maze below.
(You are still allowed to use no more than 12 blocks.)
Try this out in a new window ...
Maze Tutorial Start
Example 1 - Using loops
Example 2 - Using using if blocks
The Raspberry Pi Foundation runs the UK Bebras Challenge. Discover free teaching resources, tools, and expert support for computing education at raspberrypi.org.