-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Units won't be idle after moving #61
Comments
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 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) |
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.
The text was updated successfully, but these errors were encountered: