List of Wrappers

Gymnasium provides a number of commonly used wrappers listed below. More information can be found on the particular wrapper in the page on the wrapper type

Name

Description

AtariPreprocessing

Implements the common preprocessing techniques for Atari environments (excluding frame stacking).

Autoreset

The wrapped environment is automatically reset when an terminated or truncated state is reached.

ClipAction

Clips the action pass to step to be within the environment’s action_space.

ClipReward

Clips the rewards for an environment between an upper and lower bound.

DelayObservation

Adds a delay to the returned observation from the environment.

DtypeObservation

Modifies the dtype of an observation array to a specified dtype.

FilterObservation

Filters a Dict or Tuple observation spaces by a set of keys or indexes.

FlattenObservation

Flattens the environment’s observation space and each observation from reset and step functions.

FrameStackObservation

Stacks the observations from the last N time steps in a rolling manner.

GrayscaleObservation

Converts an image observation computed by reset and step from RGB to Grayscale.

HumanRendering

Allows human like rendering for environments that support “rgb_array” rendering.

JaxToNumpy

Wraps a Jax-based environment such that it can be interacted with NumPy arrays.

JaxToTorch

Wraps a Jax-based environment so that it can be interacted with PyTorch Tensors.

MaxAndSkipObservation

Skips the N-th frame (observation) and return the max values between the two last observations.

NormalizeObservation

Normalizes observations to be centered at the mean with unit variance.

NormalizeReward

Normalizes immediate rewards such that their exponential moving average has a fixed variance.

NumpyToTorch

Wraps a NumPy-based environment such that it can be interacted with PyTorch Tensors.

OrderEnforcing

Will produce an error if step or render is called before render.

PassiveEnvChecker

A passive environment checker wrapper that surrounds the step, reset and render functions to check they follows gymnasium’s API.

RecordEpisodeStatistics

This wrapper will keep track of cumulative rewards and episode lengths.

RecordVideo

Records videos of environment episodes using the environment’s render function.

RenderCollection

Collect rendered frames of an environment such render returns a list[RenderedFrame].

AddRenderObservation

Includes the rendered observations in the environment’s observations.

RescaleAction

Affinely (linearly) rescales a Box action space of the environment to within the range of [min_action, max_action].

RescaleObservation

Affinely (linearly) rescales a Box observation space of the environment to within the range of [min_obs, max_obs].

ReshapeObservation

Reshapes Array based observations to a specified shape.

ResizeObservation

Resizes image observations using OpenCV to a specified shape.

StickyAction

Adds a probability that the action is repeated for the same step function.

TimeAwareObservation

Augment the observation with the number of time steps taken within an episode.

TimeLimit

Limits the number of steps for an environment through truncating the environment if a maximum number of timesteps is exceeded.

TransformAction

Applies a function to the action before passing the modified value to the environment step function.

TransformObservation

Applies a function to the observation received from the environment’s reset and step that is passed back to the user.

TransformReward

Applies a function to the reward received from the environment’s step.

Vector only Wrappers

Name

Description

DictInfoToList

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

VectorizeTransformAction

Vectorizes a single-agent transform action wrapper for vector environments.

VectorizeTransformObservation

Vectorizes a single-agent transform observation wrapper for vector environments.

VectorizeTransformReward

Vectorizes a single-agent transform reward wrapper for vector environments.