Skip to content
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

Open
oxrock opened this issue Jun 28, 2018 · 3 comments
Open

Units won't be idle after moving #61

oxrock opened this issue Jun 28, 2018 · 3 comments

Comments

@oxrock
Copy link

oxrock commented Jun 28, 2018

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.

@k4pran
Copy link

k4pran commented Jul 10, 2018

Are you selecting the self.units group or creating your own subgroups / unit objects? Can you paste the code snippet?

@oxrock
Copy link
Author

oxrock commented Jul 10, 2018

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.

@RedPlatypus
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants