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

"AssertionError: Units object is empty" if all minerals have been mined #268

Open
Saloshp opened this issue Apr 28, 2019 · 2 comments
Open
Assignees

Comments

@Saloshp
Copy link

Saloshp commented Apr 28, 2019

mf = self.state.mineral_field.closest_to(idle_worker)

When no more mineral fields are left, an assertion exception is thrown

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/sc2/main.py", line 144, in _play_game_ai
    await ai.on_step(iteration)
  File "./main.py", line 500, in on_step
    await self.distribute_workers()
  File "/usr/local/lib/python3.7/site-packages/sc2/bot_ai.py", line 276, in distribute_workers
    mf = self.state.mineral_field.closest_to(idle_worker)
  File "/usr/local/lib/python3.7/site-packages/sc2/units.py", line 163, in closest_to
    assert self, "Units object is empty"
AssertionError: Units object is empty
@tweakimp
Copy link
Contributor

thank you for this report.
the distribute workers function is far from optimal and mostly just to get you started without having to worry about worker micro when you start to write a bot

if you want to have something that is more polished, you will have to write your own function for this
i will change this to be safe for lategame scenarios with no minerals left, but keep in mind that this function is not perfect and never will be.

@tweakimp tweakimp self-assigned this Apr 30, 2019
@tweakimp
Copy link
Contributor

tweakimp commented May 1, 2019

Fixed in #270

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

2 participants