Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
The turtle can not double back to where it was before and the program should stop before jr crosses the line.
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: 41Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started