python-sc2 icon indicating copy to clipboard operation
python-sc2 copied to clipboard

Error on max() of empty set when assigning workers.

Open ErkCurley opened this issue 6 years ago • 0 comments

In the bot_ai line 386:

target_mineral = max(local_minerals, key=lambda mineral: mineral.mineral_contents)

When the worker runs out of gas at an extraction site it will look for a mineral site to mine from. If none are available the program crashes because it will return an empty set to find the max of.

A simple fix is adding a check for an empty set prior to calling the max function:
if local_minerals:

ErkCurley avatar Sep 12 '19 22:09 ErkCurley