Dentosal / python-sc2

A StarCraft II bot api client library for Python 3
MIT License
586 stars 182 forks source link

How do I determine what building can train each unit? #194

Closed You-Honey closed 5 years ago

You-Honey commented 5 years ago

How to select the correct building when all I know is the bot wants to build ZEALOT and or PROBE?

I don't want to create a huge if else chain to be able to build all units.

Here's a pseudo example:

unit = ZEALOT

building_type = get_unit_building_type(unit) <-- How to do this?

building = get_single_building(building_type)

self.do(building.train(unit))
ceacar commented 5 years ago

as a beginner, here is a way i can think of

trainable = { "gateway": [ZEALOTS, STALKER, ...], ... }

tweakimp commented 5 years ago

You can query the buildings abilities with get_available_abilities from bot_ai.py

tweakimp commented 5 years ago

Note that these queries can take a long time, its probably best to save the result for each building type and only redo the query some tech requirement finished. I think this is solved then, feel free to reopen if there is something else.