From d0968c373960eb13e61e9472d5d49cc94394b921 Mon Sep 17 00:00:00 2001 From: Aditya Payanadan <144642015+AdityaPayanadan@users.noreply.github.com> Date: Fri, 10 Oct 2025 02:18:15 +1030 Subject: [PATCH] Update bot_ai.py Without self.do it will not access vespene gas for some reason. Also changed it so that it considers possible mining places whereas previously it was considering deficit mining places for some reason even after sorting --- sc2/bot_ai.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sc2/bot_ai.py b/sc2/bot_ai.py index a4bcfb86..6c5f66cc 100644 --- a/sc2/bot_ai.py +++ b/sc2/bot_ai.py @@ -273,7 +273,7 @@ def is_near_to_expansion(t): return closest - async def distribute_workers(self, resource_ratio: float = 2) -> None: + async def distribute_workers(self, resource_ratio: float = 2) -> None: """ Distributes workers across all the bases taken. Keyword `resource_ratio` takes a float. If the current minerals to gas @@ -353,13 +353,13 @@ async def distribute_workers(self, resource_ratio: float = 2) -> None: if not possible_mining_places: possible_mining_places = deficit_mining_places # find closest mining place - current_place = min(deficit_mining_places, key=lambda place: place.distance_to(worker)) + current_place = min(possible_mining_places, key=lambda place: place.distance_to(worker)) + # remove it from the list deficit_mining_places.remove(current_place) # if current place is a gas extraction site, go there if current_place.vespene_contents: - worker.gather(current_place) - # if current place is a gas extraction site, + self.do(worker.gather(current_place)) # go to the mineral field that is near and has the most minerals left else: local_minerals = ( @@ -368,17 +368,17 @@ async def distribute_workers(self, resource_ratio: float = 2) -> None: # local_minerals can be empty if townhall is misplaced target_mineral = max(local_minerals, key=lambda mineral: mineral.mineral_contents, default=None) if target_mineral: - worker.gather(target_mineral) + self.do(worker.gather(target_mineral)) # more workers to distribute than free mining spots # send to closest if worker is doing nothing elif worker.is_idle and all_minerals_near_base: target_mineral = min(all_minerals_near_base, key=lambda mineral: mineral.distance_to(worker)) - worker.gather(target_mineral) + self.do(worker.gather(target_mineral)) else: # there are no deficit mining places and worker is not idle # so dont move him pass - + @property_cache_once_per_frame def owned_expansions(self) -> dict[Point2, Unit]: """Dict of expansions owned by the player with mapping {expansion_location: townhall_structure}."""