Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixxed max_iter_crashes #80

Merged
merged 1 commit into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading