Petting Zoo Vector Base Class

Base class for vectorized pettingzoo environments.

Parameters

class agilerl.vector.pz_vec_env.PettingZooVecEnv(num_envs: int, observation_spaces: Dict[str, Space], action_spaces: List[Space], possible_agents: List[str])

An abstract asynchronous, vectorized environment

References:

https://github.com/openai/baselines/tree/master/baselines/common/vec_env https://github.com/Farama-Foundation/Gymnasium/blob/main/gymnasium/vector/vector_env.py

Parameters:
  • num_envs (int) – Number of environments to vectorize

  • observation_spaces (dict[str, gymnasium.spaces.Space]) – Dictionary of observation spaces

  • action_spaces (list[gymnasium.spaces.Space]) – List of action spaces

  • possible_agents (list[str]) – List of possible agents

close(**kwargs: Any) None

Clean up the environments’ resources.

close_extras(**kwargs: Any) None

Clean up the extra resources e.g. beyond what’s in this base class.

render() Any

Returns the rendered frames from the parallel environments.

reset(seed: int | None = None, options: Dict[str, Any] | None = None) Dict[str, Any]

Reset all the environments and return two dictionaries of batched observations and infos.

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

  • options (dict[str, Any]) – Options dictionary

step(actions: Dict[str, ndarray]) Dict[str, ndarray] | Dict[str, Any]

Take an action for each parallel environment

Parameters:

actions (dict[str, np.ndarray]) – Dictionary of vectorized actions for each agent.

step_async(actions: List[List[int | float | ndarray | Tensor]]) None

Tell all the environments to start taking a step with the given actions. Call step_wait() to get the results of the step. You should not call this if a step_async run is already pending.

Parameters:

actions (list[list[int | float | np.ndarray]]) – List of lists of length num_envs, each sub list contains actions for each agent in a given environment

step_wait() Dict[str, ndarray] | Dict[str, Any]

Wait for the step taken with step_async().

property unwrapped: PettingZooVecEnv

Return the base environment.