def _find_closest_to_target(self, from_pos: Point2, grid: np.ndarray) -> Point2: try: nearest_spot = grid[np.sum( np.square(np.abs(grid - np.array([[from_pos.x, from_pos.y]]))), 1, ).argmin()] pos = Point2(Pointlike((nearest_spot[0], nearest_spot[1]))) return pos except ValueError: return from_pos.towards(self.bot.start_location, 1)
def _find_existing_tumor_placement(self, from_pos: Point2) -> Optional[Point2]: # find closest no creep tile that is in pathing grid target: Point2 = self._find_closest_to_target(from_pos, self.no_creep_map) # start at possible placement area, and move back till we find a spot for i in range(self.policy.distance_between_existing_tumors): new_pos: Point2 = from_pos.towards( target, self.policy.distance_between_existing_tumors - i) if (self.bot.is_visible(new_pos) and self.bot.has_creep(new_pos) and self.bot.in_pathing_grid(new_pos)): return new_pos
def adjust_build_to_move(self, position: Point2) -> Point2: closest_zone = position.closest( map_to_point2s_center(self.knowledge.expansion_zones)) return position.towards(closest_zone, 1)