Question: Python The turtle can not double back to where it was before and the program should stop before jr crosses the line. my idea was

Python Python The turtle can not double back to where it was before

The turtle can not double back to where it was before and the program should stop before jr crosses the line.

and the program should stop before jr crosses the line. my idea

was to use a tuple to keep track of where the turtle

my idea was to use a tuple to keep track of where the turtle has already been and stop it if it tries to revisit. I am have trouble visualizing what needs to be done.

Random walk, like we showed in class today. BUT... you can't go to any place you've already been. If the path crosses itself anywhere, it's wrong. Example at right: (The little circle is the origin) The path ends at the arrowhead, because it's totally blocked, it can't go up, down, left or right. FYI, attached is what we did in class.. pyjny import turtle import random draw = turtle. Turtle() postion = () #keep track of where it went|| box = [(0,50), (50,0),(-50,0), (0,-50)] #stay in box x, y = random.choice(box) position = set() currentposition = turtle.xcor(), turtle.ycor() dx, dy = random.choice (box) #where to go X+=dx y+=dy draw.goto(x,y) Ln: 6 Col: 41

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!