Vector Environment Wrappers#

class gymnasium.experimental.vector.VectorWrapper(env: VectorEnv)#

Wraps the vectorized environment to allow a modular transformation.

This class is the base class for all wrappers for vectorized environments. The subclass could override some methods to change the behavior of the original vectorized environment without touching the original code.

Note

Don’t forget to call super().__init__(env) if the subclass overrides __init__().

Initialize the vectorized environment wrapper.

Vector Lambda Observation Wrappers#

class gymnasium.experimental.vector.VectorObservationWrapper(env: VectorEnv)#

Wraps the vectorized environment to allow a modular transformation of the observation. Equivalent to gym.ObservationWrapper for vectorized environments.

Initialize the vectorized environment wrapper.

Vector Lambda Action Wrappers#

class gymnasium.experimental.vector.VectorActionWrapper(env: VectorEnv)#

Wraps the vectorized environment to allow a modular transformation of the actions. Equivalent of ActionWrapper for vectorized environments.

Initialize the vectorized environment wrapper.

Vector Lambda Reward Wrappers#

class gymnasium.experimental.vector.VectorRewardWrapper(env: VectorEnv)#

Wraps the vectorized environment to allow a modular transformation of the reward. Equivalent of RewardWrapper for vectorized environments.

Initialize the vectorized environment wrapper.

Vector Common Wrappers#

class gymnasium.experimental.wrappers.vector.VectorRecordEpisodeStatistics(env: VectorEnv, deque_size: int = 100)#

wrapped_env.return_queue and wrapped_env.length_queue respectively.

Variables:
  • return_queue – The cumulative rewards of the last deque_size-many episodes

  • length_queue – The lengths of the last deque_size-many episodes

Parameters:
  • env (Env) – The environment to apply the wrapper

  • deque_size – The size of the buffers return_queue and length_queue

Vector Only Wrappers#

class gymnasium.experimental.wrappers.vector.VectorListInfo(env: VectorEnv)#

Converts infos of vectorized environments from dict to List[dict].

This wrapper converts the info format of a vector environment from a dictionary to a list of dictionaries. This wrapper is intended to be used around vectorized environments. If using other wrappers that perform operation on info like RecordEpisodeStatistics this need to be the outermost wrapper.

i.e. VectorListInfo(RecordEpisodeStatistics(envs))

Example:

>>> # actual
>>> {  
...      "k": np.array([0., 0., 0.5, 0.3]),
...      "_k": np.array([False, False, True, True])
...  }
>>> # classic
>>> [{}, {}, {k: 0.5}, {k: 0.3}]  
Parameters:

env (Env) – The environment to apply the wrapper