from World import * from random import * import math import sys class Tagger(Turtle): def __init__(self, world, speed=1, clumsiness=60, color='red'): Turtle.__init__(self, world) self.delay = 0 self.speed = speed self.clumsiness = clumsiness self.color = color # move to the starting position self.pu() self.rt(randint(0,360)) self.fd(150) self.rt(180) def step(self): # step is invoked whenever the turtle is supposed to move # add code here to refine how turtles play Tag # make a random turn and move # note: do not remove these three lines dir = randint(0,self.clumsiness) - randint(0,self.clumsiness) self.rt(dir) self.fd(self.speed) # create TurtleWorld world = TurtleWorld() world.delay = .01 world.setup_run() # make three Taggers with different speed and clumsiness attributes color = [None, 'orange', 'green', 'purple' ] for i in range(1,4): t = Tagger(world, i, i*30, color[i]) world.mainloop()