Skip to content

Commit

Permalink
Add action result and alerts observations.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 196657275
  • Loading branch information
tewalds committed May 15, 2018
1 parent e9c083c commit 1f1c447
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,16 @@ observation.
A `(n)` tensor listing all the action ids that were made successfully since the
last observation. An action that was attempted but failed is not included here.

##### Action Result

A `(n)` tensor (usually size 1) giving the result of the action. The values are
listed in
[error.proto](https://github.com/Blizzard/s2client-proto/blob/master/s2clientprotocol/error.proto)

##### Alerts

A `(n)` tensor (usually empty, occasionally size 1, max 2) for when you're being attacked in a major way.

### Actions

The SC2 action space is very big. There are hundreds of possible actions, many
Expand Down
7 changes: 7 additions & 0 deletions pysc2/lib/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,8 @@ def observation_spec(self):
units you have selected.
"""
obs_spec = named_array.NamedDict({
"action_result": (0,), # See error.proto: ActionResult.
"alerts": (0,), # See sc2api.proto: Alert.
"available_actions": (0,),
"build_queue": (0, len(UnitLayer)), # pytype: disable=wrong-arg-types
"cargo": (0, len(UnitLayer)), # pytype: disable=wrong-arg-types
Expand Down Expand Up @@ -574,6 +576,11 @@ def or_zeros(layer, size):
[self.reverse_action(a).function for a in obs.actions],
dtype=np.int32)

out["action_result"] = np.array([o.result for o in obs.action_errors],
dtype=np.int32)

out["alerts"] = np.array(obs.observation.alerts, dtype=np.int32)

out["game_loop"] = np.array([obs.observation.game_loop], dtype=np.int32)

score_details = obs.observation.score.score_details
Expand Down

0 comments on commit 1f1c447

Please sign in to comment.