Skip to content

Commit

Permalink
Merge pull request #80 from FredNoonienSingh/76-fix-max-iter-depth-cr…
Browse files Browse the repository at this point in the history
…ashes

fixxed max_iter_crashes
  • Loading branch information
FredNoonienSingh authored Jan 11, 2025
2 parents e0229a7 + 9d85dbd commit 71817a1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
36 changes: 18 additions & 18 deletions bot/HarstemsAunt/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,22 @@ async def on_step(self, iteration:int):
for t in threads:
t.join()

if not self.macro.build_order.opponent_builds_air:
if [unit for unit in self.seen_enemies if unit.is_flying and unit.can_attack]:
self.macro.build_order.opponent_builds_air = True
await self.chat_send("I see you got an AirForce, i can do that too")

if not self.macro.build_order.opponent_has_detection:
if [unit for unit in self.seen_enemies if unit.is_flying and unit.can_attack]:
self.macro.build_order.opponent_has_detection = True

if not self.macro.build_order.opponent_uses_cloak:
if [unit for unit in self.seen_enemies if (unit.is_cloaked and unit.can_attack) or (unit.is_burrowed and unit.can_attack)]:
self.macro.build_order.opponent_uses_cloak = True
await self.chat_send("Stop hiding and fight like a honorable ... \
ähm... Robot?\ndo computers have honor ?")


self.pathing.update(iteration)

for j, group in enumerate(self.army_groups):
Expand Down Expand Up @@ -272,26 +288,10 @@ async def on_enemy_unit_entered_vision(self, unit:Unit) -> None:
Args:
unit (Unit): Unit
"""
if not unit.tag in self.seen_enemies and unit.type_id not in WORKER_IDS:
self.seen_enemies.append(unit.tag)
if not unit in self.seen_enemies and unit.type_id not in WORKER_IDS:
self.seen_enemies.append(unit)
self.enemy_supply += self.calculate_supply_cost(unit.type_id)

if not self.macro.build_order.opponent_builds_air:
if unit.is_flying and unit.can_attack:
self.macro.build_order.opponent_builds_air = True
await self.chat_send("I see you got an AirForce, i can do that too")

#TODO: #76 Fix max iter depth crashes
if not self.macro.build_order.opponent_has_detection:
if unit.is_detector:
self.macro.build_order.opponent_has_detection = True

if not self.macro.build_order.opponent_uses_cloak:
if (unit.is_cloaked and unit.can_attack) \
or (unit.is_burrowed and unit.can_attack):
self.macro.build_order.opponent_uses_cloak = True
await self.chat_send("Stop hiding and fight like a honorable ... \
ähm... Robot?\ndo computers have honor ?")
#TODO: #73 Implement on_enemy_unit_left_vision logic
async def on_enemy_unit_left_vision(self, unit_tag:int):
""" Coroutine gets called when enemy left vision
Expand Down
14 changes: 14 additions & 0 deletions bot/HarstemsAunt/map_sector.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,20 @@ def in_sector(self,unit:Unit) -> bool:
min_y, max_y = self.upper_left.y,self.lower_right.y
return min_x <= unit.position.x <= max_x and min_y <= unit.position.y <= max_y

def find_ramps_in_sector(self, ramp: Point2) -> List[Point2]:
""" Finds the Ramp within the sector
Args:
ramp (Point2): returns the top of the ramp
Returns:
List[Point2]: of Top - center Point of the Ramp
"""
min_x, max_x = self.upper_left.x, self.lower_right.x
min_y, max_y = self.upper_left.y,self.lower_right.y
top_x, top_y = ramp.top_center.x, ramp.top_center.y
return min_x <= top_x <= max_x and min_y <= top_y <= max_y

def build_sector(self) -> None:
"""This should be implemented differently and will be reworked """
self.ramps = self.ramps_in_sector()
Expand Down

0 comments on commit 71817a1

Please sign in to comment.