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

can_afford() sometimes leads to ERROR:sc2.bot_ai:Error: ActionResult.NotSupported #41

Open
ghost opened this issue May 28, 2018 · 2 comments
Labels

Comments

@ghost
Copy link

ghost commented May 28, 2018

Ordering a unit by larvae sometimes resulting in getting an error:
ERROR:sc2.bot_ai:Error: ActionResult.NotSupported (action: UnitCommand(AbilityId.LARVATRAIN_DRONE, Unit(name='Larva', tag=4314628097), None, False))

I believe this is because the method can_afford() of the class sc2.BotAI sometimes returning true even if we cannot afford the unit.
This is happening, I assuming, because there are sequential queue of orders that happening one frame (step) after another, and the information that can_afford() is referring to is not keeping up to date.

@Hannessa
Copy link

Yeah, I think it's the same issue I reported here: #38

It should get better if you run Realtime=False, or if you add a small delay in your on_step() method, e.g:

await asyncio.sleep(0.02)

(Need to "import asyncio" at top)

But it's definitely a bug, although it might be a bug in the Blizzard API rather than python-sc2, I'm not sure.

@ghost
Copy link
Author

ghost commented May 28, 2018

I thought about adding delay too, but thought about it as an ugly hack.
Solved problem other way, by checking if larva is able to morph a unit:

larva = self.larvae.random
abilities = await self.get_available_abilities(larva)
if AbilityId.LARVATRAIN_DRONE in abilities:
    await self.do(larva.train(DRONE))

There perhaps an artificial delay built in into the game mechanics that prevents larvae to morph units every frame.

@Dentosal Dentosal added the bug label May 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants