# Walks along the walls # of a room. # # version 3 def turn_right(): repeat(turn_left, 3) # Mark starting point. put_beeper() # Turn left until it's clear # in front of you; then move # forward. while not front_is_clear(): turn_left() move() # As long as there is no beeper # turn right, if possible; if not # go straight, if possible; if not # turn left. while not on_beeper(): if right_is_clear(): turn_right() move() elif front_is_clear(): move() else: turn_left() pick_beeper() turn_off()