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
makekeeps the registered spec's value and the constructor its default.
- AddRenderObservation<TObs, TAct>
Puts the rendered frame into every observation, as Gymnasium's
AddRenderObservationdoes: withrender_onlythe frame replaces the observation, otherwise it joins it in a dict (beside aDict'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
makekeeps 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
AddWhiteNoisedoes; withAddRenderObservationit 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
makekeeps the registered spec's value and the constructor its default.
- ClipAction<TObs, TAct>
Clips every action into the env's
Boxbounds before the env sees it, as Gymnasium'sClipActiondoes; 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
makekeeps the registered spec's value and the constructor its default.
- ClipReward<TObs, TAct>
Clips every reward into
[min_reward, max_reward], as Gymnasium'sClipRewarddoes; 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
makekeeps the registered spec's value and the constructor its default.
- DelayObservation<TObs, TAct>
Delays every observation by
delaysteps, as Gymnasium'sDelayObservationdoes: until the delay has passed, the wrapper returns the space's zero (CreateZeroArray(Space)), then the observation the env returneddelaysteps 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
makekeeps 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'sDiscretizeActiondoes: oneDiscretenumber (row-major over the box's elements) or aMultiDiscretevector 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
makekeeps the registered spec's value and the constructor its default.
- DiscretizeObservation<TObs, TAct>
Discretizes a finite
Boxobservation uniformly, as Gymnasium'sDiscretizeObservationdoes: each of the box's elements intobinsequal bins, the indices combined into oneDiscretenumber (row-major) or kept apart as aMultiDiscretevector.
- 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
makekeeps the registered spec's value and the constructor its default.
- DtypeObservation<TObs, TAct>
Converts every observation to a dtype, as Gymnasium's
DtypeObservationdoes: aBox,MultiDiscreteorMultiBinaryobservation keeps its shape, aDiscreteone 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
makekeeps the registered spec's value and the constructor its default.
- FilterObservation<TObs, TAct>
Keeps only some keys of a
Dictobservation, or some indices of aTupleone, as Gymnasium'sFilterObservationdoes; 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
makekeeps 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'sFlattenObservationdoes: aDictorTupleof arrays becomes one array, aDiscretea 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
makekeeps the registered spec's value and the constructor its default.
- FrameStackObservation<TObs, TAct>
Stacks the last
stack_sizeobservations along a new first axis, as Gymnasium'sFrameStackObservationdoes: the space isbatch_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
makekeeps 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'sGrayscaleObservationdoes;keep_dimkeeps 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
makekeeps 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
HumanRenderingdoes: every reset and step renders the env and shows the frame atmetadata["render_fps"], so the wrapper's render mode ishuman.makeadds it whenrender_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
makekeeps the registered spec's value and the constructor its default.
- MaxAndSkipObservation<TObs, TAct>
Repeats each action for
skipsteps, sums the rewards, and returns the element-wise maximum of the last two observations, as Gymnasium'sMaxAndSkipObservationdoes: 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
makekeeps 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
NormalizeObservationdoes, 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
makekeeps 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
NormalizeRewarddoes, 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
makekeeps 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
ObstructViewdoes: aboutobstructed_pixels_ratioof the pixels in patchesobstruction_widthwide.
- 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
makekeeps the registered spec's value and the constructor its default.
- OrderEnforcing<TObs, TAct>
Raises ResetNeeded when
steporrenderis called before the firstreset, a mistake that would otherwise fail somewhere inside the env with a less helpful error.makeadds it unless the spec disablesorder_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.
makeadds it beneathOrderEnforcingunlessdisable_env_checkeris 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
makekeeps 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 lastbuffer_lengthepisodes 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
makekeeps 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
RecordVideodoes: a recording starts when the episode or step trigger fires (by default episodes 0, 1, 8, 27, ..., 729, then every 1000th), lasts the episode orvideo_lengthframes, 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
makekeeps 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*_listrender modes.makeadds it whenrender_mode="rgb_array_list"is asked of an env that rendersrgb_arrayitself.
- 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
makekeeps the registered spec's value and the constructor its default.
- RepeatAction<TObs, TAct>
Steps the env
num_repeatstimes with each action, sums the rewards, and returns the last step's observation, flags and info, as Gymnasium'sRepeatActiondoes: 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
makekeeps 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'sBoxbounds, as Gymnasium'sRescaleActiondoes (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
makekeeps the registered spec's value and the constructor its default.
- RescaleObservation<TObs, TAct>
Rescales a
Boxobservation affinely onto[min_obs, max_obs], as Gymnasium'sRescaleObservationdoes; 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
makekeeps the registered spec's value and the constructor its default.
- ReshapeObservation<TObs, TAct>
Reshapes every array observation, as Gymnasium's
ReshapeObservationdoes; 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
makekeeps 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'sResizeObservationdoes withcv2.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
makekeeps 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 ofrepeat_action_durationsteps, as Gymnasium'sStickyActiondoes (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
makekeeps 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
TimeAwareObservationdoes: aDictobservation gets atimekey, aTupleone 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
makekeeps 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
truncatedsignal comes from for envs that have no limit of their own, as opposed toterminated, which the MDP decides.makeadds it when the spec hasmax_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
makekeeps 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
TransformActiondoes. 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
makekeeps the registered spec's value and the constructor its default.
- TransformObservation<TWObs, TObs, TAct>
Applies a function to every observation
ResetandStepreturn, as Gymnasium'sTransformObservationdoes. 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
makekeeps the registered spec's value and the constructor its default.
- TransformReward<TObs, TAct>
Applies a function to every reward
Stepreturns, as Gymnasium'sTransformRewarddoes.
- WrapperFunctions
Gymnasium's
gymnasium.wrappers.utilsfunctions that this phase's wrappers use.