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

How do I determine which type of unit has a given ability #173

Open
b2coutts opened this issue Nov 27, 2018 · 3 comments
Open

How do I determine which type of unit has a given ability #173

b2coutts opened this issue Nov 27, 2018 · 3 comments
Labels

Comments

@b2coutts
Copy link

I'm trying to make an AI that doesn't hardcode any of the tech tree, and instead infers it from the _game_data attribute of the bot at runtime. So far I'm able to pretty much build the tech tree from _game_data.units, using the tech_requirement attribute; this lets me build the tech tree as far as buildings.

The problem is with incorporating army units and research. For instance, colossi can be seen to depend on a robotics bay from its tech_requirement field, but an immortal has no tech_requirement, but you need a robotics facility to build it. All units have a creation_ability field, but there's no way to see which building can use that ability. Upgrades have the same problem.

So basically, my question is: is there a way to check, given a particular ability, which unit type(s) can use that ability? Or is there some other way to be able to tell which buildings can create which units programmatically?

@BurnySc2
Copy link
Collaborator

As far as I know, this is a missing feature from the API.

I have hardcoded it in my bots to build units and research upgrades only from specific buildings under certain circumstances.
This function could help you

python-sc2/sc2/bot_ai.py

Lines 121 to 124 in 695faf2

async def get_available_abilities(self, units: Union[List[Unit], Units], ignore_resource_requirements=False) -> List[List[AbilityId]]:
""" Returns available abilities of one or more units. """
# right know only checks cooldown, energy cost, and whether the ability has been researched
return await self._client.query_available_abilities(units, ignore_resource_requirements)

to find out the abilities of your structures, but seeing how you write it, it sounds like you want to know at game start which buildings and units can use what abilities.

@b2coutts
Copy link
Author

Yeah, I was ideally hoping to build the tech tree at game start so the bot would know what its branching options are; maybe I'll just hardcode these parts of the tech tree. Thanks for the response!

@BurnySc2
Copy link
Collaborator

By the way, the terran units ghost, thor and battlecruiser should list techlab and their appropriate requirement (ghost academy, armory, fusion core respectively) but they only list None (at least the last time I checked).

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

No branches or pull requests

2 participants