python-sc2
python-sc2 copied to clipboard
Cache expansion_locations
trafficstars
Arent they cached here?
Seems like they are. I'll verify that this before closing.
The issue is that expansion_locations needs to be called once for the values to be cached.
If the call is made for the first time inside on_step() function it can cause a timeout for the whole bot.
Our bot currently handles the first call like below, but I feel the python-sc2 library should already have the values cached.
def _prepare_first_step(self):
"""First step extra preparations. Must not be called before _prepare_step."""
sc2.BotAI._prepare_first_step(self)
# Call expansion_locations so they are cached for the rest of the game.
# This can take a long time! Hopefully this overridden method
# will not be subject to the timeout limit.
self.expansion_locations.keys()