You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a simple bot script where I am trying to issue a stop command to workers to stop and do nothing. I have the following script:
importsc2importsc2.actionfromsc2.bot_aiimportBotAIimportsc2.constantsimportsc2.game_dataimportsc2.idsfromsc2.playerimportBot, Computerfromsc2.ids.unit_typeidimportUnitTypeIdimportosimportsc2.unitimportsc2.unitsos.environ["SC2PATH"] ="C:\\sc2\\StarCraft II"defstop_all_units(bot: BotAI):
''' Stop all units by cancelling all active and pending orders '''#u: sc2.unit.Unit = bot.units[0]#o: sc2.unit.UnitOrder = u.orders[0]#a: sc2.unit.AbilityId = o.abilityprint("Stopping all workers")
forworkerinbot.workers:
ifworker:
print(f"{type(worker.hold_position)}{type(worker.stop)}")
worker.stop()
classSimpleBot(BotAI):
asyncdefon_step(self, iteration):
globalHasInformedUnitsInfo#print_info(bot=self, iteration=iteration)#if not HasInformedUnitsInfo:stop_all_units(self)
#HasInformedUnitsInfo = Truesc2.run_game(
sc2.maps.get("AcropolisLE"),
[Bot(sc2.Race.Zerg, SimpleBot()), Computer(sc2.Race.Zerg, sc2.Difficulty.Hard)],
realtime=True
)
The above is the code I have. On every iteration, stop_all_units is executed and I can see the printed statements on the command prompt. However, once the game starts, the workers start gathering minerals and don't stop. I have also tried hold_position() on the worker objects without success and also tried worker.move(bot.start_location.position) to move them to a spot and stop gathering.
None of the above worked for me. Are there any other ways to do this or did I miss something? I am new to SC2 and maybe what I am trying makes no sense. Some pointers will be highly appreciated.
The text was updated successfully, but these errors were encountered:
I have a simple bot script where I am trying to issue a stop command to workers to stop and do nothing. I have the following script:
The above is the code I have. On every iteration,
stop_all_units
is executed and I can see the printed statements on the command prompt. However, once the game starts, the workers start gathering minerals and don't stop. I have also triedhold_position()
on the worker objects without success and also triedworker.move(bot.start_location.position)
to move them to a spot and stop gathering.None of the above worked for me. Are there any other ways to do this or did I miss something? I am new to SC2 and maybe what I am trying makes no sense. Some pointers will be highly appreciated.
The text was updated successfully, but these errors were encountered: