def radar_updated(self): while True: radar = yield coords = self.coords closest, dist = self._find_closest(radar, coords) if dist is not None: # distance to closest is None if there are no other robots self.heading = get_heading_p2p(coords, closest) # Hunt self.speed = settings['max_speed'] # Kill. Attacking is free. Why not do it all the time? self.attack()
def radar_updated(self): while True: radar = yield coords = self.coords closest, dist = self._find_closest(radar, coords) if dist is not None: # distance to closest is None if there are no other robots self.heading = get_heading_p2p(coords, closest) # Hunt # TODO: Reduce speed as we approach self.speed = settings['max_speed'] # Kill. if dist < 3: self.attack()
def _move_to_middle(self, coords=None): """ Sets heading and speed to move to the middle of the battlefield """ if coords is None: coords = self.coords # Move to middle middle = self._get_middle() # Set heading self.heading = get_heading_p2p(coords, middle) # Set speed # TODO: Set speed according to how close we are self.speed = settings['max_speed']