Skip to content

Commit

Permalink
feat: MDRamp offset attribute for walloff, corner_walloff, middle_wal…
Browse files Browse the repository at this point in the history
…loff_depot properties
  • Loading branch information
eladyaniv01 committed Nov 7, 2020
1 parent be13d59 commit 5fb232c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions MapAnalyzer/constructs.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,24 +86,26 @@ def __init__(self, map_data: "MapData", array: np.ndarray, ramp: sc2Ramp) -> Non
super().__init__(map_data=map_data, array=array)
self.is_ramp = True
self.ramp = ramp
self.x_offset = 0.5
self.y_offset = 0.5
self.offset = Point2((0.5, 0.5))
self.points.add(Point2(self.middle_walloff_depot.rounded))

@property
def corner_walloff(self):
raw_points = sorted(list(self.points), key=lambda x: x.distance_to_point2(self.bottom_center), reverse=True)[:2]
offset_points = [p.offset((self.x_offset, self.y_offset)) for p in raw_points]
offset_points = [p.offset(self.offset) for p in raw_points]
offset_points.extend(raw_points)
return offset_points

@property
def middle_walloff_depot(self):
raw_points = sorted(list(self.points), key=lambda x: x.distance_to_point2(self.bottom_center), reverse=True)
# TODO its white board time, need to figure out some geometric intuition here
intersects = raw_points[0].circle_intersection(p=raw_points[1], r=2.5 ** 0.5)
r = max(self.map_data.distance(raw_points[0], raw_points[1]) ** 0.5,
self.map_data.distance(raw_points[0], raw_points[1]) / 2)
intersects = raw_points[0].circle_intersection(p=raw_points[1], r=r)
# p = self.map_data.closest_towards_point(points=self.buildables.points, target=self.top_center)
p = max(intersects, key=lambda p: p.distance_to_point2(self.bottom_center))
return p
pt = max(intersects, key=lambda p: p.distance_to_point2(self.bottom_center))
return pt.offset(self.offset)

def closest_region(self, region_list):
"""
Expand Down

0 comments on commit 5fb232c

Please sign in to comment.