Question: Highschool Back Tracking. Looking for a simple code in python for a back tracking robot car that is supposed to travel through the maze. The

Highschool Back Tracking.

Looking for a simple code in python for a back tracking robot car that is supposed to travel through the maze. The car has a distance sensor and when it detects a crossroad it chooses a path and explores it. when it comes to a dead end I want it to turn around and retrace its steps and get back at the point where it was when it was at the cross point. I want it to

So...

1) Store all movements in a stack.

2) When at a cross roads mark that cross road

3) Continue storing movement in a stack

4) When sensor detect that the car is at a dead end the car will turn 180 degree. (I already have the function to make a 180 when at a dead end so You can just put in a place holder here ans I can plug it in. What I need from you is how to connect this to the next part.)

5) Car will now do the opposite movements it had done to go back to the crossroads place.

here is how the car moves and turns

 def turn_ROBOT_90(direction): """   :param direction: positive is right, negative is left  :return:  """  if direction >= 0: degrees = 90 else: degrees = -90 var.ROBOT.turn_degrees(degrees,True) 
def turn_left(): degrees = -90 var.ROBOT.turn_degrees(degrees,True) def turn_right(): degrees = 90 var.ROBOT.turn_degrees(degrees,True) def turn_around(): degrees = 180 var.ROBOT.turn_degrees(degrees,True)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!