If, Else

On these maps, the path turns, always to the right, but in different places on each map. So on every tile, the dog has to choose between two options: if there's a path ahead, it moves forward, and otherwise it turns right.

The If … else block chooses between two options. It has two mouths:

  • If path ahead
    • Move forward
  • else
    • Turn right ↻

When the condition is true, the blocks in the upper mouth are carried out. When it's false, the blocks in the lower one, after the word else, are carried out. So exactly one of the two parts is always carried out, never both and never neither.

Put this decision in a Repeat until at the goal loop. On every pass, the dog either moves or turns, and that way it gets all the way to the goal, wherever the path turns.

Instructions

Get the dog to the goal on all three maps.

Start programming for free

By signing up, you agree to the Terms of Service and Privacy Policy.

Or sign up with:

2/4