Petting Zoo Wrapper

Parameters

class agilerl.wrappers.pettingzoo_wrappers.PettingZooAutoResetParallelWrapper(env: ParallelEnv[AgentID, ObsType, ActionType])

Wrapper to automatically reset the environment when all agents terminate or truncate.

Parameters:

env (ParallelEnv[AgentID, ObsType, ActionType]) – The environment to wrap

action_space(agent: AgentID) spaces.Space

Return the action space for the given agent.

Parameters:

agent (str) – Agent ID

Returns:

Action space

Return type:

spaces.Space

close() None

Close the environment.

observation_space(agent: AgentID) spaces.Space

Return the observation space for the given agent.

Parameters:

agent (str) – Agent ID

Returns:

Observation space

Return type:

spaces.Space

render() None | ndarray | str | list

Render the environment.

Returns:

Rendered environment

Return type:

None | np.ndarray | str | list

reset(seed: int | None = None, options: dict | None = None) tuple[dict[AgentID, ObsType], dict[AgentID, dict]]

Reset the environment and return the initial observations and info.

Parameters:
  • seed (int | None, optional) – Random seed, defaults to None

  • options (dict | None, optional) – Options dictionary, defaults to None

Returns:

Tuple of (observations, infos)

Return type:

tuple[dict[str, np.ndarray], dict[str, Any]]

property state: ndarray

Return the state of the environment.

Returns:

State of the environment

Return type:

np.ndarray

step(actions: dict[AgentID, ActionType]) tuple[dict[AgentID, ObsType], dict[AgentID, float], dict[AgentID, bool], dict[AgentID, bool], dict[AgentID, dict]]

Step the environment and return the observations, rewards, terminations, truncations, and info.

Parameters:

actions (dict[str, ActionType]) – Actions dictionary

Returns:

Tuple of (observations, rewards, terminations, truncations, infos)

Return type:

tuple[dict[str, np.ndarray], dict[str, float], dict[str, bool], dict[str, bool], dict[str, Any]]

property unwrapped: ParallelEnv

Return the unwrapped environment.

Returns:

Unwrapped environment

Return type:

ParallelEnv