Units won't be idle after moving
After I do something like this: await self.do(unit.move(target.position)) That unit will never go back to being idle even after it's made it to the location. Currently I'm having to keep a list of units I moved, checking their distance from the desired location and manually calling unit.stop() so that they'll have cleared orders again.
Are you selecting the self.units group or creating your own subgroups / unit objects? Can you paste the code snippet?
I was simply grabbing idle units iterating through something similar to self.units(MARINE).ready.is_idle and then assigning all those idle units to move somewhere individually. Even after those units reach their destination, they will never show as idle for the remainder of the game. In my case I was simply telling them to rally at my command center before launching an attack.
My work around for this is to simply use the attack command and supplying a position instead. This has the added effect of allowing them to actually protect themselves on route.
I didn't find this to be the case with Probes. Here's a quick example to try.
import sc2
from sc2 import run_game, maps, Race, Difficulty, position
from sc2.player import Bot, Computer
from sc2.constants import NEXUS, PROBE, PYLON
class TestBot(sc2.BotAI):
def __init__(self):
self.moved_workers = False
self.got_idle = False
async def on_step(self, iteration):
if not self.moved_workers:
self.moved_workers = True
# get position
top_cen = self.game_info.map_ramps[0].top_center
go_to = position.Point2(position.Pointlike(top_cen))
# get workers
workers = self.units(PROBE)
for w in workers:
await self.do(w.move(go_to))
if iteration > 4500 and not self.got_idle:
self.got_idle = True
# get position
top_cen = self.game_info.map_ramps[1].top_center
go_to = position.Point2(position.Pointlike(top_cen))
# get idle workers
workers = self.units(PROBE).idle
for w in workers:
await self.do(w.move(go_to))
# start a probe just to be sure of when frame 4500 occurs
for nexus in self.units(NEXUS).ready:
if self.can_afford(PROBE):
await self.do(nexus.train(PROBE))
run_game(maps.get("NeonVioletSquareLE"), [
Bot(Race.Protoss, TestBot()),
Computer(Race.Terran, Difficulty.Easy)
], realtime=True)