Do expansion occupation checking first before querying pathing
This is to not waste the query on an occupied expansion.
@@ -81,17 +81,16 @@ class BotAI(object):
closest = None
distance = float("inf")
for el in self.expansion_locations:
- th = self.townhalls.first
- d = await self._client.query_pathing(th.position, el)
- if d is None:
- continue
-
def is_near_to_expansion(t): return t.position.distance_to(el) < DISTANCE_THRESHOLD
-
if any([t for t in map(is_near_to_expansion, self.townhalls)]):
# already taken
continue
+ th = self.townhalls.first
+ d = await self._client.query_pathing(th.position, el)
+ if d is None:
+ continue
+
if d < distance:
distance = d
closest = el
