示例#1
0
 def waypoint_step(self, action, value):
     if action in Vector.directions:
         d = Vector.unit(action)
         self.waypoint += d * value
     elif action == 'L':
         while value > 0:
             self.waypoint.rotate_left_90()
             value -= 90
     elif action == 'R':
         while value > 0:
             self.waypoint.rotate_right_90()
             value -= 90
     elif action == 'F':
         d = self.waypoint
         self.pos += d * value
     else:
         raise Exception('Unknown action')
示例#2
0
 def __init__(self):
     self.pos = Vector.null()
     self.dir = Vector.unit('E')
     self.waypoint = Vector(10, 1)