GithubHelp home page GithubHelp logo

Comments (2)

Hannessa avatar Hannessa commented on June 15, 2024

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

from python-sc2.

reypader avatar reypader commented on June 15, 2024

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

from python-sc2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.