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

Cache expansion_locations

Open Dentosal opened this issue 6 years ago • 3 comments
trafficstars

Dentosal avatar Jan 12 '19 20:01 Dentosal

Arent they cached here?

tweakimp avatar Jan 13 '19 09:01 tweakimp

Seems like they are. I'll verify that this before closing.

Dentosal avatar Jan 13 '19 17:01 Dentosal

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()

merfolk avatar Jan 13 '19 18:01 merfolk