I tried to pass in a turtle, I know what I've done didn't make sense so far but I just trying to make a turtle run as x and y cor, I couldn't figure out how to change them.
def takeOnePaStep():
direction = random.randint(0,3)
if direction == 0:
return (0,1)
elif direction == 1:
return (1,0)
elif direction == 2:
return (0,-1)
elif direction == 3:
return (-1,0)
def randomWalkPa(Pa_steps):
pa = [0,0]
for _ in range (Pa_steps):
nextStep = takeOnePaStep()
pa[0] += nextStep[0]
pa[1] += nextStep[1]
pasDistance = hypot(pa[0],pa[1])
return pasDistance
for _ in range (Pa_steps):
Pa = turtle.Turtle()
Pa.shape("circle")
Pa.pensize(1)
Pa.speed(0)
Pa.goto(pa[0],pa[1])
This part right here, I feel like they can represent as x and y var but I'm really stuck on how to call them
pa[0] += nextStep[0]
pa[1] += nextStep[1]
Aucun commentaire:
Enregistrer un commentaire