Beispiel #1
0
 def go_to_xy(self, x, y):
     d = int_distance(self.x, self.y, x, y)
     if d > self.radius:
         # execute action
         self.o = int_angle(self.x, self.y, x, y)  # turn towards the goal
         self._reach(d)
     else:
         return True
Beispiel #2
0
 def go_to_xy(self, x, y):
     d = int_distance(self.x, self.y, x, y)
     if d > self.radius:
         # execute action
         self.o = int_angle(self.x, self.y, x, y) # turn towards the goal
         self._reach(d)
     else:
         return True
Beispiel #3
0
 def action_reach_and_use(self):
     target = self.action_target
     if not self._near_enough_to_use(target):
         d = int_distance(self.x, self.y, target.x, target.y)
         self.o = int_angle(self.x, self.y, target.x, target.y) # turn toward the goal
         self._reach(d - target.collision_range(self))
     else:
         self.walked = []
         target.be_used_by(self)
Beispiel #4
0
 def action_reach_and_use(self):
     target = self.action_target
     if not self._near_enough_to_use(target):
         d = int_distance(self.x, self.y, target.x, target.y)
         self.o = int_angle(self.x, self.y, target.x,
                            target.y)  # turn toward the goal
         self._reach(d - target.collision_range(self))
     else:
         self.walked = []
         target.be_used_by(self)
Beispiel #5
0
 def action_fly_to_remote_target(self):
     dmax = int_distance(self.x, self.y, self.action_target.x, self.action_target.y)
     self.o = int_angle(self.x, self.y, self.action_target.x, self.action_target.y) # turn toward the goal
     self._d = self.speed * VIRTUAL_TIME_INTERVAL / 1000 # used by _future_coords and _heuristic_value
     x, y = self._future_coords(0, dmax)
     if not self.place.contains(x, y):
         try:
             new_place = self.world.get_place_from_xy(x, y)
             self.move_to(new_place, x, y, self.o)
         except:
             exception("problem when flying to a new square")
     else:
         self.move_to(self.place, x, y)
Beispiel #6
0
 def _shift(self, xc, yc):
     # shift angle to have central symmetry and map balance
     # (distance from the townhall to the resources)
     return int_angle(xc, yc, self.col * 10 + 5, self.row * 10 + 5)
Beispiel #7
0
 def _shift(self, xc, yc):
     # shift angle to have central symmetry and map balance
     # (distance from the townhall to the resources)
     return int_angle(xc, yc, self.col * 10 + 5, self.row * 10 + 5)