Skip to content

Commit

Permalink
Merge pull request #123 from AresSC2/fix/overproduce-low-tech
Browse files Browse the repository at this point in the history
fix: overproduce on low tech behaves as expected
  • Loading branch information
raspersc2 authored Mar 30, 2024
2 parents 6b020c2 + 4eb78c1 commit ba95876
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/ares/behaviors/macro/spawn_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ def execute(self, ai: "AresBot", config: dict, mediator: ManagerMediator) -> boo
proportion_sum: float = 0.0
# remember units that meet tech requirement
units_ready_to_build: list[UnitID] = []
# keep track of what units we have tech for
tech_ready_for: list[UnitID] = []
# iterate through desired army comp starting with the highest priority unit
for unit_type_id, army_comp_info in sorted(
army_comp_dict.items(), key=lambda x: x[1].get("priority", int(0))
Expand All @@ -111,6 +113,8 @@ def execute(self, ai: "AresBot", config: dict, mediator: ManagerMediator) -> boo
if not ai.tech_ready_for_unit(unit_type_id):
continue

tech_ready_for.append(unit_type_id)

# get all idle build structures/units we can create this unit from
build_structures: list[Unit] = ai.get_build_structures(
UNIT_TRAINED_FROM[unit_type_id],
Expand Down Expand Up @@ -157,7 +161,11 @@ def execute(self, ai: "AresBot", config: dict, mediator: ManagerMediator) -> boo
ai, unit_type_id, build_structures, amount, supply, cost
)
# if we can only build one type of unit, keep adding them
if len(units_ready_to_build) == 1 and self.over_produce_on_low_tech:
if (
len(tech_ready_for) == 1
and self.over_produce_on_low_tech
and len(units_ready_to_build) > 0
):
build_structures = ai.get_build_structures(
UNIT_TRAINED_FROM[units_ready_to_build[0]],
units_ready_to_build[0],
Expand Down

0 comments on commit ba95876

Please sign in to comment.