BurnySc2 / python-sc2

A StarCraft II bot api client library for Python 3
MIT License
491 stars 157 forks source link

Function BotAI.research() not returning correct result #191

Open DrKwojn opened 7 months ago

DrKwojn commented 7 months ago

Description for function BotAI.research states that the result should only be True if the upgrade was started. But the function will return True even if the research is not started because of the structure needed to research the upgrade not being finished. https://github.com/BurnySc2/python-sc2/blob/f175e8160762dcba9a1524b3491cf5f522e01fde/sc2/bot_ai.py#L1080-L1085

The problem seems to be that the condition checking for an available structure to do the research does not check if the structure has finished building. https://github.com/BurnySc2/python-sc2/blob/f175e8160762dcba9a1524b3491cf5f522e01fde/sc2/bot_ai.py#L1136-L1152

Example 1:

self.research(UpgradeId.ZERGMISSILEWEAPONSLEVEL1)

Will return True if there is only one evolution chamber and if it is not finished, but it should be False.

Example 2:

self.research(UpgradeId.GLIALRECONSTITUTION)

Will return True if there is only one roach warren and if it is not finished, but it should be False.

Possible solution

Adding and structure.is_ready in the condition checking for an available structure would solve the issue. Not sure if there are any problems with this. https://github.com/BurnySc2/python-sc2/blob/f175e8160762dcba9a1524b3491cf5f522e01fde/sc2/bot_ai.py#L1138-L1147

Version burnysc2 6.5.0