Skip to content

Warpgate example runs extremely slow when warping in units #45

Open

Description

@Dentosal
No description provided.

Activity

  1. Hannessa commented on Jun 7, 2018

    @Hannessa

    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
    
  2. reypader commented on Jun 28, 2018

    @reypader
    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions