Table of Contents

Namespace Gym.Wrappers

Classes

AddRenderObservationOptions

The keyword arguments of AddRenderObservation<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

AddRenderObservation<TObs, TAct>

Puts the rendered frame into every observation, as Gymnasium's AddRenderObservation does: with render_only the frame replaces the observation, otherwise it joins it in a dict (beside a Dict's keys, or as {obs_key: obs, render_key: frame}).

AddWhiteNoiseOptions

The keyword arguments of AddWhiteNoise<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

AddWhiteNoise<TObs, TAct>

Replaces each pixel of the rendered frame by white noise with a given probability, as Gymnasium's AddWhiteNoise does; with AddRenderObservation it makes pixel observations noisy, turning the MDP into a POMDP.

Autoreset<TObs, TAct>

Resets the env automatically, on the step after an episode ends (Gymnasium's vector autoreset order): that step ignores its action, resets the env and returns the first observation with reward 0 and both signals false, so a loop never needs to call reset after the first.

ClipActionOptions

The keyword arguments of ClipAction<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

ClipAction<TObs, TAct>

Clips every action into the env's Box bounds before the env sees it, as Gymnasium's ClipAction does; the wrapper's own action space is unbounded (Box(-inf, inf) of the same shape and dtype), since any action is accepted.

ClipRewardOptions

The keyword arguments of ClipReward<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

ClipReward<TObs, TAct>

Clips every reward into [min_reward, max_reward], as Gymnasium's ClipReward does; either bound may be left out.

DelayObservationOptions

The keyword arguments of DelayObservation<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

DelayObservation<TObs, TAct>

Delays every observation by delay steps, as Gymnasium's DelayObservation does: until the delay has passed, the wrapper returns the space's zero (CreateZeroArray(Space)), then the observation the env returned delay steps earlier. Use it to test an agent's tolerance of stale observations.

DiscretizeActionOptions

The keyword arguments of DiscretizeAction<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

DiscretizeAction<TObs, TAct>

Takes discrete actions and steps the env with the center of the matching bin of its finite Box, as Gymnasium's DiscretizeAction does: one Discrete number (row-major over the box's elements) or a MultiDiscrete vector of one index per element.

DiscretizeObservationOptions

The keyword arguments of DiscretizeObservation<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

DiscretizeObservation<TObs, TAct>

Discretizes a finite Box observation uniformly, as Gymnasium's DiscretizeObservation does: each of the box's elements into bins equal bins, the indices combined into one Discrete number (row-major) or kept apart as a MultiDiscrete vector.

DtypeObservationOptions

The keyword arguments of DtypeObservation<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

DtypeObservation<TObs, TAct>

Converts every observation to a dtype, as Gymnasium's DtypeObservation does: a Box, MultiDiscrete or MultiBinary observation keeps its shape, a Discrete one becomes a 0-d array of the dtype (a NumPy scalar), and the space follows.

FilterObservationOptions

The keyword arguments of FilterObservation<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

FilterObservation<TObs, TAct>

Keeps only some keys of a Dict observation, or some indices of a Tuple one, as Gymnasium's FilterObservation does; the space is filtered the same way.

FlattenObservationOptions

The keyword arguments of FlattenObservation<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

FlattenObservation<TObs, TAct>

Flattens every observation into a 1-D array (spaces.utils.flatten), with the flattened space (flatten_space) as the observation space, as Gymnasium's FlattenObservation does: a Dict or Tuple of arrays becomes one array, a Discrete a one-hot vector.

FrameStackObservationOptions

The keyword arguments of FrameStackObservation<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

FrameStackObservation<TObs, TAct>

Stacks the last stack_size observations along a new first axis, as Gymnasium's FrameStackObservation does: the space is batch_space(env.observation_space, stack_size), and after a reset the stack is padded with the reset's observation ("reset", the default), the space's zero ("zero"), or a given element. Use it to give a memoryless agent motion (velocities from frames).

GrayscaleObservationOptions

The keyword arguments of GrayscaleObservation<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

GrayscaleObservation<TObs, TAct>

Converts an RGB image observation to grayscale (0.2125 R + 0.7154 G + 0.0721 B, truncated to uint8), as Gymnasium's GrayscaleObservation does; keep_dim keeps a channel axis of length 1.

HumanRenderingOptions

The keyword arguments of HumanRendering<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

HumanRendering<TObs, TAct>

Shows an env that renders images in a window, as Gymnasium's HumanRendering does: every reset and step renders the env and shows the frame at metadata["render_fps"], so the wrapper's render mode is human. make adds it when render_mode="human" is asked of an env that only renders images.

MaxAndSkipObservationOptions

The keyword arguments of MaxAndSkipObservation<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

MaxAndSkipObservation<TObs, TAct>

Repeats each action for skip steps, sums the rewards, and returns the element-wise maximum of the last two observations, as Gymnasium's MaxAndSkipObservation does: the frame skipping of Atari agents, where the maximum removes the flicker of sprites drawn on alternate frames.

NormalizeObservationOptions

The keyword arguments of NormalizeObservation<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

NormalizeObservation<TObs, TAct>

Normalizes every observation to roughly zero mean and unit variance by running statistics of the observations seen so far, as Gymnasium's NormalizeObservation does, byte for byte: float32 statistics, float32 results.

NormalizeRewardOptions

The keyword arguments of NormalizeReward<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

NormalizeReward<TObs, TAct>

Scales rewards so their exponential moving average has roughly unit variance: every reward is divided by the square root of the running variance (plus Epsilon) of a discounted return, as Gymnasium's NormalizeReward does, byte for byte.

ObstructViewOptions

The keyword arguments of ObstructView<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

ObstructView<TObs, TAct>

Covers random square patches of the rendered frame with white noise, as Gymnasium's ObstructView does: about obstructed_pixels_ratio of the pixels in patches obstruction_width wide.

OrderEnforcingOptions

The keyword arguments of OrderEnforcing<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

OrderEnforcing<TObs, TAct>

Raises ResetNeeded when step or render is called before the first reset, a mistake that would otherwise fail somewhere inside the env with a less helpful error. make adds it unless the spec disables order_enforce.

PassiveEnvChecker<TObs, TAct>

Runs PassiveChecker's checks around the env so that a broken env is reported where it breaks: the spaces at construction, then the first reset, step and render, and whether the reset and the first step, then the first and second steps, returned shared data. Every later call is forwarded unchanged, so the checks cost nothing for the rest of the run. make adds it beneath OrderEnforcing unless disable_env_checker is set.

RecordEpisodeStatisticsOptions

The keyword arguments of RecordEpisodeStatistics<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

RecordEpisodeStatistics<TObs, TAct>

Records each episode's return, length and duration: the step that ends an episode gets info["episode"] = {"r": return, "l": length, "t": seconds}, and the last buffer_length episodes stay in ReturnQueue, LengthQueue and TimeQueue.

RecordVideoOptions

The keyword arguments of RecordVideo<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

RecordVideo<TObs, TAct>

Records videos of episodes from the env's render, as Gymnasium's RecordVideo does: a recording starts when the episode or step trigger fires (by default episodes 0, 1, 8, 27, ..., 729, then every 1000th), lasts the episode or video_length frames, and is written through an IVideoWriter as {video_folder}/{name_prefix}-episode-{i} or -step-{i}.

RenderCollectionOptions

The keyword arguments of RenderCollection<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

RenderCollection<TObs, TAct>

Collects a frame after every reset and step, so render() returns the list of frames since the last call (RenderResult.Frames) instead of the current one: the *_list render modes. make adds it when render_mode="rgb_array_list" is asked of an env that renders rgb_array itself.

RepeatActionOptions

The keyword arguments of RepeatAction<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

RepeatAction<TObs, TAct>

Steps the env num_repeats times with each action, sums the rewards, and returns the last step's observation, flags and info, as Gymnasium's RepeatAction does: a lower decision frequency, for envs whose agent need not act at every step. An episode that ends stops the repetition early.

RescaleActionOptions

The keyword arguments of RescaleAction<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

RescaleAction<TObs, TAct>

Takes actions in [min_action, max_action] and rescales them affinely onto the env's Box bounds, as Gymnasium's RescaleAction does (the inverse of RescaleBox(Space, object, object)'s map).

RescaleObservationOptions

The keyword arguments of RescaleObservation<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

RescaleObservation<TObs, TAct>

Rescales a Box observation affinely onto [min_obs, max_obs], as Gymnasium's RescaleObservation does; unbounded components must stay unbounded and are only shifted.

ReshapeObservationOptions

The keyword arguments of ReshapeObservation<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

ReshapeObservation<TObs, TAct>

Reshapes every array observation, as Gymnasium's ReshapeObservation does; the space's bounds are reshaped with it.

ResizeObservationOptions

The keyword arguments of ResizeObservation<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

ResizeObservation<TObs, TAct>

Resizes every image observation to (height, width) by OpenCV's area interpolation, as Gymnasium's ResizeObservation does with cv2.resize(obs, (width, height), interpolation=cv2.INTER_AREA); the channels, if any, are kept. Use it to shrink frames for a learner.

RunningMeanStd

A running mean and variance (RunningMeanStd), updated batch by batch with Chan et al.'s parallel algorithm: what NormalizeObservation<TObs, TAct> and NormalizeReward<TObs, TAct> normalize by. Byte for byte Gymnasium's, NumPy 2's dtype rules included: the statistics keep their dtype (float32 for an observation normalizer) until a batch of a wider dtype promotes them, and the count stays a float64.

StickyActionOptions

The keyword arguments of StickyAction<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

StickyAction<TObs, TAct>

With probability repeat_action_probability, replaces the agent's action by the previous one for a run of repeat_action_duration steps, as Gymnasium's StickyAction does (Machado et al., 2018, ยง5.2): the stochasticity that keeps an agent from memorising a deterministic env's action sequence.

TimeAwareObservationOptions

The keyword arguments of TimeAwareObservation<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

TimeAwareObservation<TObs, TAct>

Adds the episode's elapsed steps to every observation, as Gymnasium's TimeAwareObservation does: a Dict observation gets a time key, a Tuple one a last item, anything else becomes {"obs": obs, "time": time}, and by default the result is flattened into one array.

TimeLimitOptions

The keyword arguments of TimeLimit<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

TimeLimit<TObs, TAct>

Truncates the episode once MaxEpisodeSteps steps have run since the last reset. This is where the truncated signal comes from for envs that have no limit of their own, as opposed to terminated, which the MDP decides. make adds it when the spec has max_episode_steps.

TransformActionOptions<TWAct, TAct>

The keyword arguments of TransformAction<TObs, TWAct, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

TransformAction<TObs, TWAct, TAct>

Applies a function to every action before the env steps with it, as Gymnasium's TransformAction does. Give it the space of the actions it takes when they differ from the env's.

TransformObservationOptions<TWObs, TObs>

The keyword arguments of TransformObservation<TWObs, TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

TransformObservation<TWObs, TObs, TAct>

Applies a function to every observation Reset and Step return, as Gymnasium's TransformObservation does. Give it the transformed observations' space when they leave the env's.

TransformRewardOptions

The keyword arguments of TransformReward<TObs, TAct>'s constructor as a typed record (DR-34), generated from the constructor so it cannot drift from it. A property that is set becomes a keyword argument by its Python name; one left unset is not passed, so make keeps the registered spec's value and the constructor its default.

TransformReward<TObs, TAct>

Applies a function to every reward Step returns, as Gymnasium's TransformReward does.

WrapperFunctions

Gymnasium's gymnasium.wrappers.utils functions that this phase's wrappers use.