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: dict[str, Space], possible_agents: list[str], *, metadata: dict[str, Any] | None = None, render_mode: str | None = None)¶
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:
- property action_space¶
Return callable to get an agent’s action space.
- close_extras(*, timeout: float | None = None, terminate: bool = False, **kwargs: Any) None¶
Clean up the extra resources e.g. beyond what’s in this base class.
Subclasses may override with compatible signatures (same params or wider).
- property observation_space¶
Return callable to get an agent’s observation space.
- reset(*, seed: int | None = None, options: dict[str, Any] | None = None) tuple[dict[str, ndarray], dict[str, Any]]¶
Reset all the environments and return two dictionaries of batched observations and infos.
- property single_action_space¶
Return callable to get an agent’s single action space.
- property single_observation_space¶
Return callable to get an agent’s single observation space.
- step(actions: dict[str, ndarray], *args: Any, **kwargs: Any) tuple[dict[str, ndarray | dict[str, ndarray] | tuple[ndarray, ...]], dict[str, ndarray], dict[str, ndarray], dict[str, ndarray], dict[str, Any]]¶
Take an action for each parallel environment.
- step_async(actions: list[dict[str, 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 of dictionaries of length num_envs, each sub dictionary contains
actions for each agent in a given environment :type actions: list[dict[str, int | float | np.ndarray]]
- step_wait(timeout: float | None = None) tuple[dict[str, ndarray | dict[str, ndarray] | tuple[ndarray, ...]], dict[str, ndarray], dict[str, ndarray], dict[str, ndarray], dict[str, Any]]¶
Wait for the step taken with step_async().
- Parameters:
timeout – Number of seconds before the call times out. If
None, never times out.
- property unwrapped: PettingZooVecEnv¶
Return the base environment.