DevonCurrent / ProtossAgent-RL

Starcraft 2 protoss agent using RL and DeepMind's PySC2
1 stars 1 forks source link

get_units_by_type() function #4

Open chauvinfish opened 6 years ago

chauvinfish commented 6 years ago

def get_units_by_type(self, obs, unit_type): return [unit for unit in obs.observation.feature_units if unit.unit_type == unit_type] it's a brilliant idea to count units. the orginal tutorial used a complicated and magical way like depot_y, depot_x = (unit_type == _TERRAN_SUPPLY_DEPOT).nonzero() supply_depot_count = int(round(len(depot_y) / 69))

So where did you find the obs.observation.feature_units this member property? I need a document badly

DevonCurrent commented 6 years ago

Yeah, the zerg tutorial used that function, which makes it really easy for the agent to see if there are units on the screen. The feature_units can be found at: https://github.com/deepmind/pysc2/blob/65f8badf1b3cbc0d711a8d4c87e4501225b1c0fa/pysc2/lib/features.py#L128