Skip to content

Commit

Permalink
Radar is only defined if you use raw or feature units.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 271529030
  • Loading branch information
tewalds committed Sep 27, 2019
1 parent a957b58 commit 05b28ef
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions pysc2/lib/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,6 @@ def observation_spec(self):
"multi_select": (0, len(UnitLayer)),
"player": (len(Player),),
"production_queue": (0, len(ProductionQueue)),
"radar": (0, len(Radar)),
"score_cumulative": (len(ScoreCumulative),),
"score_by_category": (len(ScoreByCategory), len(ScoreCategories)),
"score_by_vital": (len(ScoreByVital), len(ScoreVitals)),
Expand Down Expand Up @@ -1094,6 +1093,9 @@ def observation_spec(self):
obs_spec["raw_units"] = (0, len(FeatureUnit))
obs_spec["raw_effects"] = (0, len(EffectPos))

if aif.use_feature_units or aif.use_raw_units:
obs_spec["radar"] = (0, len(Radar))

obs_spec["upgrades"] = (0,)

if aif.use_unit_counts:
Expand Down Expand Up @@ -1526,12 +1528,13 @@ def cargo_units(u, pos_transform, is_raw=False):
if player_id != player.player_id:
out["away_race_requested"] = np.array((race,), dtype=np.int32)

def transform_radar(radar):
p = self._world_to_minimap_px.fwd_pt(point.Point.build(radar.pos))
return p.x, p.y, radar.radius
out["radar"] = named_array.NamedNumpyArray(
list(map(transform_radar, obs.observation.raw_data.radar)),
[None, Radar], dtype=np.int32)
if aif.use_feature_units or aif.use_raw_units:
def transform_radar(radar):
p = self._world_to_minimap_px.fwd_pt(point.Point.build(radar.pos))
return p.x, p.y, radar.radius
out["radar"] = named_array.NamedNumpyArray(
list(map(transform_radar, obs.observation.raw_data.radar)),
[None, Radar], dtype=np.int32)

# Send the entire proto as well (in a function, so it isn't copied).
if self._send_observation_proto:
Expand Down

0 comments on commit 05b28ef

Please sign in to comment.