Amazing - part 3

As you should have noticed the program doesn't work. What happens is that Reeborg gets in an infinite loop when there is no wall around him. We need to have him move() after turning right, as indicated below:

def turn_right():
    repeat(turn_left, 3)

put_beeper()
move()
while not next_to_a_beeper():
    if right_is_clear():
        turn_right()
        move()
    elif front_is_clear():
        move()
    else:
        turn_left()

turn_off()

3. More complicated world

Now, consider the world illustrated below. Will our program work?

around the world: start

Unfortunately the answer is no. Try to figure out why before reading any further.

previous Amazing - part2 - home - Amazing - part 4 next
../images/SourceForge.net Logo