# My utility robot class class MyRobot(UsedRobot): def turn_around(self): self.turn_left() self.turn_left() def turn_right(self): for i in range(3): self.turn_left() # class for setting up pins in a bowling arrangement class PinWorker(MyRobot): # function to set up a standard set of bowling pins # preconditions: at location of "head" pin w/10 beepers facing North # postconditions: at right edge of "fifth" row facing north. # This is 4 ave's east and 4 streets north of head pin. def setUpPins(self): for i in range(4): self.layRow(i) # function to lay a row of pins # preconditions: At right edge of row to lay facing north # postconditions: At right edge of row i+1 facing north def layRow(self, cnt): self.turn_left() for i in range(cnt+1): self.put_beeper() self.move() self.move() self.turn_around() for i in range((2*(cnt+1))+1): self.move() self.turn_left() self.move() # program to set up bowling pins bob = PinWorker(1,1,'E', 10) bob.set_trace_style(colour='white') # move bob to starting location for i in range(5): bob.move() bob.turn_left() bob.move() bob.setUpPins() # Move bob out of the way bob.turn_left() for i in range(4): bob.move() bob.turn_left() bob.turn_off()