Skip to content

Commit e170ff9

Browse files
authored
Merge pull request #165 from SamOgon-one/patch-2
Start locations position rounding
2 parents cc8d335 + 7a3a833 commit e170ff9

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

sc2/game_info.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,9 @@ def __init__(self, proto):
231231
p.player_id: p.race_actual or p.race_requested
232232
for p in self._proto.player_info
233233
}
234-
self.start_locations: List[Point2] = [Point2.from_proto(sl) for sl in self._proto.start_raw.start_locations]
234+
self.start_locations: List[Point2] = [
235+
Point2.from_proto(sl).round(decimals=1) for sl in self._proto.start_raw.start_locations
236+
]
235237
self.player_start_location: Point2 = None # Filled later by BotAI._prepare_first_step
236238

237239
def _find_ramps_and_vision_blockers(self) -> Tuple[List[Ramp], FrozenSet[Point2]]:

sc2/position.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,14 @@ def to2(self) -> Point2:
190190
def to3(self) -> Point3:
191191
return Point3((*self, 0))
192192

193-
def offset(self, p: Point2):
193+
def round(self, decimals: int) -> Point2:
194+
"""Rounds each number in the tuple to the amount of given decimals."""
195+
return Point2((round(self[0], decimals), round(self[1], decimals)))
196+
197+
def offset(self, p: Point2) -> Point2:
194198
return Point2((self[0] + p[0], self[1] + p[1]))
195199

196-
def random_on_distance(self, distance):
200+
def random_on_distance(self, distance) -> Point2:
197201
if isinstance(distance, (tuple, list)): # interval
198202
distance = distance[0] + random.random() * (distance[1] - distance[0])
199203

0 commit comments

Comments
 (0)