Skip to content

Commit

Permalink
v.1.6 should be ready now
Browse files Browse the repository at this point in the history
  • Loading branch information
FredNoonienSingh committed Jan 4, 2025
1 parent ea09610 commit 0102186
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 11 deletions.
15 changes: 9 additions & 6 deletions bot/HarstemsAunt/macro.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ async def marco(bot:BotAI, worker, build_pos) -> None:
get_upgrades(bot)
await build_army(bot)
await build_supply(bot, build_pos)
await expand(bot)
if bot.units(UnitTypeId.CYBERNETICSCORE) \
or bot.already_pending(UnitTypeId.CYBERNETICSCORE):
await expand(bot)
handle_alerts(bot, bot.alert)

if bot.time < 180:
await game_start(bot, worker)
#if bot.time < 180:
# await game_start(bot, worker)

for townhall in bot.townhalls:
minerals = bot.expansion_locations_dict[townhall.position].mineral_field
Expand All @@ -45,11 +47,12 @@ async def marco(bot:BotAI, worker, build_pos) -> None:

if townhall.is_ready and bot.structures(UnitTypeId.PYLON) \
and bot.structures(UnitTypeId.GATEWAY) and\
len(bot.structures(UnitTypeId.ASSIMILATOR)) < bot.gas_count \
len(bot.structures(UnitTypeId.ASSIMILATOR)) < len(bot.structures(UnitTypeId.NEXUS).ready)*2 \
and not bot.already_pending(UnitTypeId.ASSIMILATOR):
await build_gas(bot, townhall)

# Build_Probes
probe_count:int = len(bot.structures(UnitTypeId.NEXUS))*16 + len(bot.structures(UnitTypeId.ASSIMILATOR))*3
if townhall.is_idle and can_build_unit(bot, UnitTypeId.PROBE) and len(bot.workers) < probe_count:
townhall.train(UnitTypeId.PROBE)
if bot.structures(UnitTypeId.PYLON):
if townhall.is_idle and can_build_unit(bot, UnitTypeId.PROBE) and len(bot.workers) < probe_count:
townhall.train(UnitTypeId.PROBE)
2 changes: 1 addition & 1 deletion bot/HarstemsAunt/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ async def on_enemy_unit_left_vision(self, unit_tag):
async def on_unit_created(self, unit):
if unit.type_id in GATEWAY_UNTIS:
self.army_groups[0].units_in_transit.append(unit.tag)
if unit.type_id == UnitTypeId.OBSERVER:
if unit.type_id == UnitTypeId.OBSERVER or unit.type_id == UnitTypeId.IMMORTAL:
self.army_groups[0].units_in_transit.append(unit.tag)

async def on_unit_type_changed(self, unit, previous_type):
Expand Down
9 changes: 7 additions & 2 deletions bot/army_group/army_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,20 @@ def merge_groups(self, army_group:ArmyGroup) -> bool:
async def attack(self, attack_target:Union[Point2, Point3, Unit]) -> None:
stalkers: Units = self.units(UnitTypeId.STALKER)
zealots: Units = self.units(UnitTypeId.ZEALOT)
Immortals: Units = self.units(UnitTypeId.IMMORTAL)
observer: Units = self.units(UnitTypeId.OBSERVER)

if stalkers:
await self.bot.stalkers.handle_attackers(
self.units(UnitTypeId.STALKER), attack_target
stalkers, attack_target
)
if Immortals:
await self.bot.stalkers.handle_attackers(
Immortals, attack_target
)
if zealots:
await self.bot.zealots.handle_attackers(
self.units(UnitTypeId.ZEALOT), attack_target
zealots, attack_target
)
if observer:
await self.bot.observers.move(
Expand Down
7 changes: 6 additions & 1 deletion bot/macro/build_army.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from sc2.bot_ai import BotAI
from sc2.ids.unit_typeid import UnitTypeId
from actions.build_army import \
build_gateway_units, build_stargate_units
build_gateway_units, build_stargate_units, build_robo_units

from HarstemsAunt.common import UNIT_COMPOSIOTION

Expand All @@ -18,3 +18,8 @@ async def build_army(bot:BotAI) -> None:
else:
await build_gateway_units(bot, UnitTypeId.ZEALOT)
# await build_stargate_units(bot, UnitTypeId.PHOENIX)

if not bot.units(UnitTypeId.OBSERVER):
await build_robo_units(bot, UnitTypeId.OBSERVER)
else:
await build_robo_units(bot, UnitTypeId.IMMORTAL)
16 changes: 15 additions & 1 deletion bot/macro/infrastructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,18 @@ async def build_infrastructure(bot:BotAI, worker:Unit, build_pos: Union[Point2,P
if not bot.structures(UnitTypeId.GATEWAY) and not bot.structures(UnitTypeId.WARPGATE) \
and can_build_structure(bot, UnitTypeId.GATEWAY):
await bot.build(UnitTypeId.GATEWAY, build_worker=worker, near=build_pos)

return
if not bot.structures(UnitTypeId.CYBERNETICSCORE) and can_build_structure(bot, UnitTypeId.CYBERNETICSCORE) \
and not bot.already_pending(UnitTypeId.CYBERNETICSCORE):
await bot.build(UnitTypeId.CYBERNETICSCORE, build_worker=worker, near=build_pos)
return
if (len(bot.structures(UnitTypeId.GATEWAY)) + len(bot.structures(UnitTypeId.WARPGATE))) < 2 and can_build_structure(bot, UnitTypeId.GATEWAY)\
and bot.structures(tech_0):
await bot.build(UnitTypeId.GATEWAY, build_worker=worker, near=build_pos)
if not bot.structures(tech_0) and can_build_structure(bot, tech_0) and not bot.already_pending(tech_0):
await bot.build(tech_0, build_worker=worker, near=build_pos)
if bot.structures(tech_0) and can_build_structure(bot, tech_1) and not bot.structures(tech_1):
await bot.build(tech_1, build_worker=worker, near=build_pos)
if (len(bot.structures(UnitTypeId.GATEWAY)) + len(bot.structures(UnitTypeId.WARPGATE))) < 2 and can_build_structure(bot, UnitTypeId.GATEWAY)\
and bot.structures(tech_1):
await bot.build(UnitTypeId.GATEWAY, build_worker=worker, near=build_pos)

0 comments on commit 0102186

Please sign in to comment.