How to get out of infinite loop for ROBIRG's maze when the "right_is_clear" for next four position?

Viewed 7
def turn_right():
    turn_left()
    turn_left()
    turn_left()    

#Roborgs maze is (5,5) #Roborgs position and face of direction will be random in a maze.

while not at_goal():       #till the robot reaches the goal this loop continues running
    if right_is_clear():   #roborgs check whether the right side is clear or not? If yes, turn right  
        turn_right()
        move()             #problem is this maze has four positions where there is no wall on the right side, when the roborgs are being placed at that position, the loop gets infinite. Position are (4,3) , (4,4) , (3,3) , (3,4).
    elif front_is_clear():
        move()
    else:
        turn_left()   
        if wall_in_front():
            turn_left()
        else:
            move()
0 Answers
Related