api.config.obs_builder

Classes

ObsBuilder

The observation builder. This class is responsible for building observations for each agent in the environment.

Module Contents

class api.config.obs_builder.ObsBuilder

Bases: Generic[api.typing.AgentID, api.typing.ObsType, api.typing.StateType, api.typing.ObsSpaceType]

The observation builder. This class is responsible for building observations for each agent in the environment.

abstract get_obs_space(agent: api.typing.AgentID) api.typing.ObsSpaceType

Function that returns the observation space type. It will be called during the initialization of the environment.

Returns:

The type of the observation space

abstract reset(agents: List[api.typing.AgentID], initial_state: api.typing.StateType, shared_info: Dict[str, Any]) None

Function to be called each time the environment is reset. Note that this does not need to return anything, the environment will call build_obs automatically after reset, so the initial observation for a policy will be constructed in the same way as every other observation.

Parameters:
  • agents – List of AgentIDs for which this ObsBuilder will return an Obs

  • initial_state – The initial game state of the reset environment.

  • shared_info – A dictionary with shared information across all config objects.

abstract build_obs(agents: List[api.typing.AgentID], state: api.typing.StateType, shared_info: Dict[str, Any]) Dict[api.typing.AgentID, api.typing.ObsType]

Function to build observations for N agents. This is where observations will be constructed every step and every reset. This function is given the current state, and it is expected that the observations returned by this function will contain information from the perspective of each agent. This function is called only once per step.

Parameters:
  • agents – List of AgentIDs for which this ObsBuilder should return an Obs

  • state – The current state of the game.

  • shared_info – A dictionary with shared information across all config objects.

Returns:

An dictionary of observations, one for each AgentID in agents.