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

Warpgate example runs extremely slow when warping in units #45

Open
Dentosal opened this issue Jun 7, 2018 · 2 comments
Open

Warpgate example runs extremely slow when warping in units #45

Dentosal opened this issue Jun 7, 2018 · 2 comments

Comments

@Dentosal
Copy link
Owner

Dentosal commented Jun 7, 2018

No description provided.

@Hannessa
Copy link

Hannessa commented Jun 7, 2018

Not sure if related, but I noticed that there are some weird issues with sc2.bot_ai.find_placement(). I noticed this when trying to make a custom warp_in function, because I couldn't get it to warp in further out from the targetted pylon, regardless of what I changed max_distance to, I kept getting placement errors, even with random_alternative=True.

I solved this by just warping in at random positions, so I didn't have to use find_placement() or query_building_placement() at all, and I sent the action manually using self._client.actions() to surpress the error logging. As a side-note, I kind of wish you could disable error-logging with an extra argument to sc2.bot_ai.do() so I could use that directly instead.

Here's my custom warp-in solution:

    async def warp_in(self, unit, location, warpgate):
        if isinstance(location, sc2.unit.Unit):
            location = location.position.to2
        elif location is not None:
            location = location.to2

        x = random.randrange(-8,8)
        y = random.randrange(-8,8)

        placement = sc2.position.Point2((location.x+x,location.y+y))

        action = warpgate.warp_in(unit, placement)
        error = await self._client.actions(action, game_data=self._game_data)

        if not error:
            cost = self._game_data.calculate_ability_cost(action.ability)
            self.minerals -= cost.minerals
            self.vespene -= cost.vespene
            return None
        else:
            return error

@reypader
Copy link
Contributor

@Dentosal , I remember having this problem way back when I was still actively contributing. It's because the API can't register a currently warping in unit as an unavailable cell. The random alternative only works if the initial cell is unavailable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants