def observation_spec(self):
    """The observation spec for the SC2 environment.

    It's worth noting that the image-like observations are in y,x/row,column
    order which is different than the actions which are in x,y order. This is
    due to conflicting conventions, and to facilitate printing of the images.

    Returns:
      The dict of observation names to their tensor shapes. Shapes with a 0 can
      vary in length, for example the number of valid actions depends on which
      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
        "cargo_slots_available": (1,),
        "control_groups": (10, 2),
        "game_loop": (1,),
        "last_actions": (0,),
        "multi_select": (0, len(UnitLayer)),  # pytype: disable=wrong-arg-types
        "player": (len(Player),),  # pytype: disable=wrong-arg-types
        "score_cumulative": (len(ScoreCumulative),),  # pytype: disable=wrong-arg-types
        "score_by_category": (len(ScoreByCategory), len(ScoreCategories)),  # pytype: disable=wrong-arg-types
        "score_by_vital": (len(ScoreByVital), len(ScoreVitals)),  # pytype: disable=wrong-arg-types
        "single_select": (0, len(UnitLayer)),  # Only (n, 7) for n in (0, 1).  # pytype: disable=wrong-arg-types
    })

    aif = self._agent_interface_format

    if aif.feature_dimensions:
      obs_spec["feature_screen"] = (len(SCREEN_FEATURES),
                                    aif.feature_dimensions.screen.y,
                                    aif.feature_dimensions.screen.x)

      obs_spec["feature_minimap"] = (len(MINIMAP_FEATURES),
                                     aif.feature_dimensions.minimap.y,
                                     aif.feature_dimensions.minimap.x)
    if aif.rgb_dimensions:
      obs_spec["rgb_screen"] = (aif.rgb_dimensions.screen.y,
                                aif.rgb_dimensions.screen.x,
                                3)
      obs_spec["rgb_minimap"] = (aif.rgb_dimensions.minimap.y,
                                 aif.rgb_dimensions.minimap.x,
                                 3)
    if aif.use_feature_units:
      obs_spec["feature_units"] = (0, len(FeatureUnit))  # pytype: disable=wrong-arg-types

    if aif.use_raw_units:
      obs_spec["raw_units"] = (0, len(FeatureUnit))

    if aif.use_unit_counts:
      obs_spec["unit_counts"] = (0, len(UnitCounts))

    if aif.use_camera_position:
      obs_spec["camera_position"] = (2,)
    return obs_spec
def observation_spec ( self ) : obs_spec = named_array . NamedDict ( { "action_result" : ( 0 , ) , "alerts" : ( 0 , ) , "available_actions" : ( 0 , ) , "build_queue" : ( 0 , len ( UnitLayer ) ) , "cargo" : ( 0 , len ( UnitLayer ) ) , "cargo_slots_available" : ( 1 , ) , "control_groups" : ( 10 , 2 ) , "game_loop" : ( 1 , ) , "last_actions" : ( 0 , ) , "multi_select" : ( 0 , len ( UnitLayer ) ) , "player" : ( len ( Player ) , ) , "score_cumulative" : ( len ( ScoreCumulative ) , ) , "score_by_category" : ( len ( ScoreByCategory ) , len ( ScoreCategories ) ) , "score_by_vital" : ( len ( ScoreByVital ) , len ( ScoreVitals ) ) , "single_select" : ( 0 , len ( UnitLayer ) ) , } ) aif = self . _agent_interface_format if aif . feature_dimensions : obs_spec [ "feature_screen" ] = ( len ( SCREEN_FEATURES ) , aif . feature_dimensions . screen . y , aif . feature_dimensions . screen . x ) obs_spec [ "feature_minimap" ] = ( len ( MINIMAP_FEATURES ) , aif . feature_dimensions . minimap . y , aif . feature_dimensions . minimap . x ) if aif . rgb_dimensions : obs_spec [ "rgb_screen" ] = ( aif . rgb_dimensions . screen . y , aif . rgb_dimensions . screen . x , 3 ) obs_spec [ "rgb_minimap" ] = ( aif . rgb_dimensions . minimap . y , aif . rgb_dimensions . minimap . x , 3 ) if aif . use_feature_units : obs_spec [ "feature_units" ] = ( 0 , len ( FeatureUnit ) ) if aif . use_raw_units : obs_spec [ "raw_units" ] = ( 0 , len ( FeatureUnit ) ) if aif . use_unit_counts : obs_spec [ "unit_counts" ] = ( 0 , len ( UnitCounts ) ) if aif . use_camera_position : obs_spec [ "camera_position" ] = ( 2 , ) return obs_spec
The observation spec for the SC2 environment.

    It's worth noting that the image-like observations are in y,x/row,column
    order which is different than the actions which are in x,y order. This is
    due to conflicting conventions, and to facilitate printing of the images.

    Returns:
      The dict of observation names to their tensor shapes. Shapes with a 0 can
      vary in length, for example the number of valid actions depends on which
      units you have selected.