def points_on_circumference_sorted(center: Point2, closest_to: Point2, radius, n=10) -> List[Point2]: """Calculates all points on the circumference of a circle, and sorts the points so that first one on the list has shortest distance to closest_to parameter.""" points = points_on_circumference(center, radius, n) closest_point = closest_to.closest(points) closest_point_index = points.index(closest_point) sorted_points = [] # Points from closest point to the end sorted_points.extend(points[closest_point_index:]) # Points from start of list to closest point (closest point not included) sorted_points.extend(points[0:closest_point_index]) return sorted_points
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)
def closest_overlord_spot_to(k: "Knowledge", target: Point2) -> Point2: if k.pathing_manager.overlord_spots: return target.closest(k.pathing_manager.overlord_spots) return target