Merge v1.0.0 (#682)

Co-authored-by: Kallinteris Andreas <30759571+Kallinteris-Andreas@users.noreply.github.com>
Co-authored-by: Jet <38184875+jjshoots@users.noreply.github.com>
Co-authored-by: Omar Younis <42100908+younik@users.noreply.github.com>
This commit is contained in:
Mark Towers
2023-11-07 13:27:25 +00:00
committed by GitHub
parent cf5f588433
commit 27f8e85051
256 changed files with 7051 additions and 13421 deletions

View File

@@ -1,29 +1,26 @@
---
title: Utils
title: Env
---
# Env
## gymnasium.Env
```{eval-rst}
.. autoclass:: gymnasium.Env
```
### Methods
## Methods
```{eval-rst}
.. autofunction:: gymnasium.Env.step
.. autofunction:: gymnasium.Env.reset
.. autofunction:: gymnasium.Env.render
.. automethod:: gymnasium.Env.step
.. automethod:: gymnasium.Env.reset
.. automethod:: gymnasium.Env.render
.. automethod:: gymnasium.Env.close
```
### Attributes
## Attributes
```{eval-rst}
.. autoattribute:: gymnasium.Env.action_space
The Space object corresponding to valid actions, all valid actions should be contained with the space. For example, if the action space is of type `Discrete` and gives the value `Discrete(2)`, this means there are two valid discrete actions: 0 & 1.
The Space object corresponding to valid actions, all valid actions should be contained with the space. For example, if the action space is of type `Discrete` and gives the value `Discrete(2)`, this means there are two valid discrete actions: `0` & `1`.
.. code::
@@ -51,29 +48,26 @@ title: Utils
The render mode of the environment determined at initialisation
.. autoattribute:: gymnasium.Env.reward_range
A tuple corresponding to the minimum and maximum possible rewards for an agent over an episode. The default reward range is set to :math:`(-\infty,+\infty)`.
.. autoattribute:: gymnasium.Env.spec
The ``EnvSpec`` of the environment normally set during :py:meth:`gymnasium.make`
```
The :class:`EnvSpec` of the environment normally set during :py:meth:`gymnasium.make`
### Additional Methods
```{eval-rst}
.. autofunction:: gymnasium.Env.close
.. autoproperty:: gymnasium.Env.unwrapped
.. autoproperty:: gymnasium.Env.np_random
```
### Implementing environments
## Implementing environments
```{eval-rst}
.. py:currentmodule:: gymnasium
When implementing an environment, the :meth:`Env.reset` and :meth:`Env.step` functions much be created describing the
dynamics of the environment.
For more information see the environment creation tutorial.
When implementing an environment, the :meth:`Env.reset` and :meth:`Env.step` functions much be created describing the dynamics of the environment. For more information see the environment creation tutorial.
```
## Creating environments
```{eval-rst}
.. py:currentmodule:: gymnasium
To create an environment, gymnasium provides :meth:`make` to initialise the environment along with several important wrappers. Furthermore, gymnasium provides :meth:`make_vec` for creating vector environments and to view all the environment that can be created use :meth:`pprint_registry`.
```

View File

@@ -1,157 +0,0 @@
---
title: Experimental
---
# Experimental
```{toctree}
:hidden:
experimental/functional
experimental/wrappers
experimental/vector
experimental/vector_wrappers
experimental/vector_utils
```
## Functional Environments
```{eval-rst}
The gymnasium ``Env`` provides high flexibility for the implementation of individual environments however this can complicate parallelism of environments. Therefore, we propose the :class:`gymnasium.experimental.FuncEnv` where each part of environment has its own function related to it.
```
## Wrappers
Gymnasium already contains a large collection of wrappers, but we believe that the wrappers can be improved to
* (Work in progress) Support arbitrarily complex observation / action spaces. As RL has advanced, action and observation spaces are becoming more complex and the current wrappers were not implemented with this mind.
* Support for Jax-based environments. With hardware accelerated environments, i.e. Brax, written in Jax and similar PyTorch based programs, NumPy is not the only game in town anymore. Therefore, these upgrades will use [Jumpy](https://github.com/farama-Foundation/jumpy), a project developed by Farama Foundation to provide automatic compatibility for NumPy, Jax and in the future PyTorch data for a large subset of the NumPy functions.
* More wrappers. Projects like [Supersuit](https://github.com/farama-Foundation/supersuit) aimed to bring more wrappers for RL, however, many users were not aware of the wrappers, so we plan to move the wrappers into Gymnasium. If we are missing common wrappers from the list provided above, please create an issue.
* Versioning. Like environments, the implementation details of wrappers can cause changes in agent performance. Therefore, we propose adding version numbers to all wrappers, i.e., `LambaActionV0`. We don't expect these version numbers to change regularly similar to environment version numbers and should ensure that all users know when significant changes could affect your agent's performance. Additionally, we hope that this will improve reproducibility of RL in the future, this is critical for academia.
* In v28, we aim to rewrite the VectorEnv to not inherit from Env, as a result new vectorized versions of the wrappers will be provided.
We aimed to replace the wrappers in gymnasium v0.30.0 with these experimental wrappers.
### Observation Wrappers
```{eval-rst}
.. py:currentmodule:: gymnasium
.. list-table::
:header-rows: 1
* - Old name
- New name
* - :class:`wrappers.TransformObservation`
- :class:`experimental.wrappers.LambdaObservationV0`
* - :class:`wrappers.FilterObservation`
- :class:`experimental.wrappers.FilterObservationV0`
* - :class:`wrappers.FlattenObservation`
- :class:`experimental.wrappers.FlattenObservationV0`
* - :class:`wrappers.GrayScaleObservation`
- :class:`experimental.wrappers.GrayscaleObservationV0`
* - :class:`wrappers.ResizeObservation`
- :class:`experimental.wrappers.ResizeObservationV0`
* - `supersuit.reshape_v0 <https://github.com/Farama-Foundation/SuperSuit/blob/314831a7d18e7254f455b181694c049908f95155/supersuit/generic_wrappers/basic_wrappers.py#L40>`_
- :class:`experimental.wrappers.ReshapeObservationV0`
* - Not Implemented
- :class:`experimental.wrappers.RescaleObservationV0`
* - `supersuit.dtype_v0 <https://github.com/Farama-Foundation/SuperSuit/blob/314831a7d18e7254f455b181694c049908f95155/supersuit/generic_wrappers/basic_wrappers.py#L32>`_
- :class:`experimental.wrappers.DtypeObservationV0`
* - :class:`wrappers.PixelObservationWrapper`
- :class:`experimental.wrappers.PixelObservationV0`
* - :class:`wrappers.NormalizeObservation`
- :class:`experimental.wrappers.NormalizeObservationV0`
* - :class:`wrappers.TimeAwareObservation`
- :class:`experimental.wrappers.TimeAwareObservationV0`
* - :class:`wrappers.FrameStack`
- :class:`experimental.wrappers.FrameStackObservationV0`
* - `supersuit.delay_observations_v0 <https://github.com/Farama-Foundation/SuperSuit/blob/314831a7d18e7254f455b181694c049908f95155/supersuit/generic_wrappers/delay_observations.py#L6>`_
- :class:`experimental.wrappers.DelayObservationV0`
```
### Action Wrappers
```{eval-rst}
.. py:currentmodule:: gymnasium
.. list-table::
:header-rows: 1
* - Old name
- New name
* - `supersuit.action_lambda_v1 <https://github.com/Farama-Foundation/SuperSuit/blob/314831a7d18e7254f455b181694c049908f95155/supersuit/lambda_wrappers/action_lambda.py#L73>`_
- :class:`experimental.wrappers.LambdaActionV0`
* - :class:`wrappers.ClipAction`
- :class:`experimental.wrappers.ClipActionV0`
* - :class:`wrappers.RescaleAction`
- :class:`experimental.wrappers.RescaleActionV0`
* - `supersuit.sticky_actions_v0 <https://github.com/Farama-Foundation/SuperSuit/blob/314831a7d18e7254f455b181694c049908f95155/supersuit/generic_wrappers/sticky_actions.py#L6>`_
- :class:`experimental.wrappers.StickyActionV0`
```
### Reward Wrappers
```{eval-rst}
.. py:currentmodule:: gymnasium
.. list-table::
:header-rows: 1
* - Old name
- New name
* - :class:`wrappers.TransformReward`
- :class:`experimental.wrappers.LambdaRewardV0`
* - `supersuit.clip_reward_v0 <https://github.com/Farama-Foundation/SuperSuit/blob/314831a7d18e7254f455b181694c049908f95155/supersuit/generic_wrappers/basic_wrappers.py#L74>`_
- :class:`experimental.wrappers.ClipRewardV0`
* - :class:`wrappers.NormalizeReward`
- :class:`experimental.wrappers.NormalizeRewardV1`
```
### Common Wrappers
```{eval-rst}
.. py:currentmodule:: gymnasium
.. list-table::
:header-rows: 1
* - Old name
- New name
* - :class:`wrappers.AutoResetWrapper`
- :class:`experimental.wrappers.AutoresetV0`
* - :class:`wrappers.PassiveEnvChecker`
- :class:`experimental.wrappers.PassiveEnvCheckerV0`
* - :class:`wrappers.OrderEnforcing`
- :class:`experimental.wrappers.OrderEnforcingV0`
* - :class:`wrappers.EnvCompatibility`
- Moved to `shimmy <https://github.com/Farama-Foundation/Shimmy/blob/main/shimmy/openai_gym_compatibility.py>`_
* - :class:`wrappers.RecordEpisodeStatistics`
- :class:`experimental.wrappers.RecordEpisodeStatisticsV0`
* - :class:`wrappers.AtariPreprocessing`
- :class:`experimental.wrappers.AtariPreprocessingV0`
```
### Rendering Wrappers
```{eval-rst}
.. py:currentmodule:: gymnasium
.. list-table::
:header-rows: 1
* - Old name
- New name
* - :class:`wrappers.RecordVideo`
- :class:`experimental.wrappers.RecordVideoV0`
* - :class:`wrappers.HumanRendering`
- :class:`experimental.wrappers.HumanRenderingV0`
* - :class:`wrappers.RenderCollection`
- :class:`experimental.wrappers.RenderCollectionV0`
```
### Environment data conversion
```{eval-rst}
.. py:currentmodule:: gymnasium
* :class:`experimental.wrappers.JaxToNumpyV0`
* :class:`experimental.wrappers.JaxToTorchV0`
* :class:`experimental.wrappers.NumpyToTorchV0`
```

View File

@@ -1,37 +0,0 @@
---
title: Functional
---
# Functional Environment
## gymnasium.experimental.FuncEnv
```{eval-rst}
.. autoclass:: gymnasium.experimental.functional.FuncEnv
.. autofunction:: gymnasium.experimental.functional.FuncEnv.initial
.. autofunction:: gymnasium.experimental.functional.FuncEnv.transition
.. autofunction:: gymnasium.experimental.functional.FuncEnv.observation
.. autofunction:: gymnasium.experimental.functional.FuncEnv.reward
.. autofunction:: gymnasium.experimental.functional.FuncEnv.terminal
.. autofunction:: gymnasium.experimental.functional.FuncEnv.state_info
.. autofunction:: gymnasium.experimental.functional.FuncEnv.step_info
.. autofunction:: gymnasium.experimental.functional.FuncEnv.transform
.. autofunction:: gymnasium.experimental.functional.FuncEnv.render_image
.. autofunction:: gymnasium.experimental.functional.FuncEnv.render_init
.. autofunction:: gymnasium.experimental.functional.FuncEnv.render_close
```
## gymnasium.experimental.func2env.FunctionalJaxCompatibilityEnv
```{eval-rst}
.. autoclass:: gymnasium.experimental.functional_jax_env.FunctionalJaxEnv
.. autofunction:: gymnasium.experimental.functional_jax_env.FunctionalJaxEnv.reset
.. autofunction:: gymnasium.experimental.functional_jax_env.FunctionalJaxEnv.step
.. autofunction:: gymnasium.experimental.functional_jax_env.FunctionalJaxEnv.render
```

View File

@@ -1,39 +0,0 @@
---
title: Vector
---
# Vectorizing Environment
## gymnasium.experimental.VectorEnv
```{eval-rst}
.. autoclass:: gymnasium.experimental.vector.VectorEnv
.. autofunction:: gymnasium.experimental.vector.VectorEnv.reset
.. autofunction:: gymnasium.experimental.vector.VectorEnv.step
.. autofunction:: gymnasium.experimental.vector.VectorEnv.close
.. autofunction:: gymnasium.experimental.vector.VectorEnv.reset
```
## gymnasium.experimental.vector.AsyncVectorEnv
```{eval-rst}
.. autoclass:: gymnasium.experimental.vector.AsyncVectorEnv
.. autofunction:: gymnasium.experimental.vector.AsyncVectorEnv.reset
.. autofunction:: gymnasium.experimental.vector.AsyncVectorEnv.step
.. autofunction:: gymnasium.experimental.vector.AsyncVectorEnv.close
.. autofunction:: gymnasium.experimental.vector.AsyncVectorEnv.call
.. autofunction:: gymnasium.experimental.vector.AsyncVectorEnv.get_attr
.. autofunction:: gymnasium.experimental.vector.AsyncVectorEnv.set_attr
```
## gymnasium.experimental.vector.SyncVectorEnv
```{eval-rst}
.. autoclass:: gymnasium.experimental.vector.SyncVectorEnv
.. autofunction:: gymnasium.experimental.vector.SyncVectorEnv.reset
.. autofunction:: gymnasium.experimental.vector.SyncVectorEnv.step
.. autofunction:: gymnasium.experimental.vector.SyncVectorEnv.close
.. autofunction:: gymnasium.experimental.vector.SyncVectorEnv.call
.. autofunction:: gymnasium.experimental.vector.SyncVectorEnv.get_attr
.. autofunction:: gymnasium.experimental.vector.SyncVectorEnv.set_attr
```

View File

@@ -1,29 +0,0 @@
---
title: Vector Utility
---
# Utility functions for vectorisation
## Spaces utility functions
```{eval-rst}
.. autofunction:: gymnasium.experimental.vector.utils.batch_space
.. autofunction:: gymnasium.experimental.vector.utils.concatenate
.. autofunction:: gymnasium.experimental.vector.utils.iterate
.. autofunction:: gymnasium.experimental.vector.utils.create_empty_array
```
## Shared memory functions
```{eval-rst}
.. autofunction:: gymnasium.experimental.vector.utils.create_shared_memory
.. autofunction:: gymnasium.experimental.vector.utils.read_from_shared_memory
.. autofunction:: gymnasium.experimental.vector.utils.write_to_shared_memory
```
## Miscellaneous
```{eval-rst}
.. autofunction:: gymnasium.experimental.vector.utils.CloudpickleWrapper
.. autofunction:: gymnasium.experimental.vector.utils.clear_mpi_env_vars
```

View File

@@ -1,53 +0,0 @@
---
title: Vector Wrappers
---
# Vector Environment Wrappers
```{eval-rst}
.. autoclass:: gymnasium.experimental.vector.VectorWrapper
```
## Vector Observation Wrappers
```{eval-rst}
.. autoclass:: gymnasium.experimental.vector.VectorObservationWrapper
.. autoclass:: gymnasium.experimental.wrappers.vector.LambdaObservationV0
.. autoclass:: gymnasium.experimental.wrappers.vector.FilterObservationV0
.. autoclass:: gymnasium.experimental.wrappers.vector.FlattenObservationV0
.. autoclass:: gymnasium.experimental.wrappers.vector.GrayscaleObservationV0
.. autoclass:: gymnasium.experimental.wrappers.vector.ResizeObservationV0
.. autoclass:: gymnasium.experimental.wrappers.vector.ReshapeObservationV0
.. autoclass:: gymnasium.experimental.wrappers.vector.RescaleObservationV0
.. autoclass:: gymnasium.experimental.wrappers.vector.DtypeObservationV0
```
## Vector Action Wrappers
```{eval-rst}
.. autoclass:: gymnasium.experimental.vector.VectorActionWrapper
.. autoclass:: gymnasium.experimental.wrappers.vector.LambdaActionV0
.. autoclass:: gymnasium.experimental.wrappers.vector.ClipActionV0
.. autoclass:: gymnasium.experimental.wrappers.vector.RescaleActionV0
```
## Vector Reward Wrappers
```{eval-rst}
.. autoclass:: gymnasium.experimental.vector.VectorRewardWrapper
.. autoclass:: gymnasium.experimental.wrappers.vector.LambdaRewardV0
.. autoclass:: gymnasium.experimental.wrappers.vector.ClipRewardV0
```
## More Vector Wrappers
```{eval-rst}
.. autoclass:: gymnasium.experimental.wrappers.vector.RecordEpisodeStatisticsV0
.. autoclass:: gymnasium.experimental.wrappers.vector.DictInfoToListV0
.. autoclass:: gymnasium.experimental.wrappers.vector.VectorizeLambdaObservationV0
.. autoclass:: gymnasium.experimental.wrappers.vector.VectorizeLambdaActionV0
.. autoclass:: gymnasium.experimental.wrappers.vector.VectorizeLambdaRewardV0
.. autoclass:: gymnasium.experimental.wrappers.vector.JaxToNumpyV0
.. autoclass:: gymnasium.experimental.wrappers.vector.JaxToTorchV0
.. autoclass:: gymnasium.experimental.wrappers.vector.NumpyToTorchV0
```

View File

@@ -1,65 +0,0 @@
---
title: Wrappers
---
# Wrappers
## Observation Wrappers
```{eval-rst}
.. autoclass:: gymnasium.experimental.wrappers.LambdaObservationV0
.. autoclass:: gymnasium.experimental.wrappers.FilterObservationV0
.. autoclass:: gymnasium.experimental.wrappers.FlattenObservationV0
.. autoclass:: gymnasium.experimental.wrappers.GrayscaleObservationV0
.. autoclass:: gymnasium.experimental.wrappers.ResizeObservationV0
.. autoclass:: gymnasium.experimental.wrappers.ReshapeObservationV0
.. autoclass:: gymnasium.experimental.wrappers.RescaleObservationV0
.. autoclass:: gymnasium.experimental.wrappers.DtypeObservationV0
.. autoclass:: gymnasium.experimental.wrappers.PixelObservationV0
.. autoclass:: gymnasium.experimental.wrappers.NormalizeObservationV0
.. autoclass:: gymnasium.experimental.wrappers.TimeAwareObservationV0
.. autoclass:: gymnasium.experimental.wrappers.FrameStackObservationV0
.. autoclass:: gymnasium.experimental.wrappers.DelayObservationV0
.. autoclass:: gymnasium.experimental.wrappers.AtariPreprocessingV0
```
## Action Wrappers
```{eval-rst}
.. autoclass:: gymnasium.experimental.wrappers.LambdaActionV0
.. autoclass:: gymnasium.experimental.wrappers.ClipActionV0
.. autoclass:: gymnasium.experimental.wrappers.RescaleActionV0
.. autoclass:: gymnasium.experimental.wrappers.StickyActionV0
```
## Reward Wrappers
```{eval-rst}
.. autoclass:: gymnasium.experimental.wrappers.LambdaRewardV0
.. autoclass:: gymnasium.experimental.wrappers.ClipRewardV0
.. autoclass:: gymnasium.experimental.wrappers.NormalizeRewardV1
```
## Other Wrappers
```{eval-rst}
.. autoclass:: gymnasium.experimental.wrappers.AutoresetV0
.. autoclass:: gymnasium.experimental.wrappers.PassiveEnvCheckerV0
.. autoclass:: gymnasium.experimental.wrappers.OrderEnforcingV0
.. autoclass:: gymnasium.experimental.wrappers.RecordEpisodeStatisticsV0
```
## Rendering Wrappers
```{eval-rst}
.. autoclass:: gymnasium.experimental.wrappers.RecordVideoV0
.. autoclass:: gymnasium.experimental.wrappers.HumanRenderingV0
.. autoclass:: gymnasium.experimental.wrappers.RenderCollectionV0
```
## Environment data conversion
```{eval-rst}
.. autoclass:: gymnasium.experimental.wrappers.JaxToNumpyV0
.. autoclass:: gymnasium.experimental.wrappers.JaxToTorchV0
.. autoclass:: gymnasium.experimental.wrappers.NumpyToTorchV0
```

34
docs/api/functional.md Normal file
View File

@@ -0,0 +1,34 @@
---
title: Functional
---
# Functional Env
```{eval-rst}
.. autoclass:: gymnasium.functional.FuncEnv
.. automethod:: gymnasium.functional.FuncEnv.transform
.. automethod:: gymnasium.functional.FuncEnv.initial
.. automethod:: gymnasium.functional.FuncEnv.initial_info
.. automethod:: gymnasium.functional.FuncEnv.transition
.. automethod:: gymnasium.functional.FuncEnv.observation
.. automethod:: gymnasium.functional.FuncEnv.reward
.. automethod:: gymnasium.functional.FuncEnv.terminal
.. automethod:: gymnasium.functional.FuncEnv.transition_info
.. automethod:: gymnasium.functional.FuncEnv.render_image
.. automethod:: gymnasium.functional.FuncEnv.render_initialise
.. automethod:: gymnasium.functional.FuncEnv.render_close
```
## Converting Jax-based Functional environments to standard Env
```{eval-rst}
.. autoclass:: gymnasium.utils.functional_jax_env.FunctionalJaxEnv
.. automethod:: gymnasium.utils.functional_jax_env.FunctionalJaxEnv.reset
.. automethod:: gymnasium.utils.functional_jax_env.FunctionalJaxEnv.step
.. automethod:: gymnasium.utils.functional_jax_env.FunctionalJaxEnv.render
```

View File

@@ -2,14 +2,13 @@
title: Registry
---
# Register and Make
# Make and register
```{eval-rst}
Gymnasium allows users to automatically load environments, pre-wrapped with several important wrappers through the :meth:`gymnasium.make` function. To do this, the environment must be registered prior with :meth:`gymnasium.register`. To get the environment specifications for a registered environment, use :meth:`gymnasium.spec` and to print the whole registry, use :meth:`gymnasium.pprint_registry`.
```
```{eval-rst}
.. autofunction:: gymnasium.make
.. autofunction:: gymnasium.make_vec
.. autofunction:: gymnasium.register
.. autofunction:: gymnasium.spec
.. autofunction:: gymnasium.pprint_registry
@@ -19,6 +18,7 @@ Gymnasium allows users to automatically load environments, pre-wrapped with seve
```{eval-rst}
.. autoclass:: gymnasium.envs.registration.EnvSpec
.. autoclass:: gymnasium.envs.registration.WrapperSpec
.. attribute:: gymnasium.envs.registration.registry
The Global registry for gymnasium which is where environment specifications are stored by :meth:`gymnasium.register` and from which :meth:`gymnasium.make` is used to create environments.
@@ -36,5 +36,4 @@ Gymnasium allows users to automatically load environments, pre-wrapped with seve
.. autofunction:: gymnasium.envs.registration.find_highest_version
.. autofunction:: gymnasium.envs.registration.namespace
.. autofunction:: gymnasium.envs.registration.load_env_creator
.. autofunction:: gymnasium.envs.registration.load_plugin_envs
```

View File

@@ -9,39 +9,38 @@ title: Spaces
spaces/fundamental
spaces/composite
spaces/utils
spaces/vector_utils
vector/utils
```
```{eval-rst}
.. automodule:: gymnasium.spaces
```
## The Base Class
```{eval-rst}
.. autoclass:: gymnasium.spaces.Space
```
### Attributes
## Attributes
```{eval-rst}
.. autoproperty:: gymnasium.spaces.space.Space.shape
.. py:currentmodule:: gymnasium.spaces
.. autoproperty:: Space.shape
.. property:: Space.dtype
Return the data type of this space.
.. autoproperty:: gymnasium.spaces.space.Space.is_np_flattenable
.. autoproperty:: Space.is_np_flattenable
.. autoproperty:: Space.np_random
```
### Methods
## Methods
Each space implements the following functions:
```{eval-rst}
.. autofunction:: gymnasium.spaces.space.Space.sample
.. autofunction:: gymnasium.spaces.space.Space.contains
.. autofunction:: gymnasium.spaces.space.Space.seed
.. autofunction:: gymnasium.spaces.space.Space.to_jsonable
.. autofunction:: gymnasium.spaces.space.Space.from_jsonable
.. py:currentmodule:: gymnasium.spaces
.. automethod:: Space.sample
.. automethod:: Space.contains
.. automethod:: Space.seed
.. automethod:: Space.to_jsonable
.. automethod:: Space.from_jsonable
```
## Fundamental Spaces
@@ -49,13 +48,13 @@ Each space implements the following functions:
Gymnasium has a number of fundamental spaces that are used as building boxes for more complex spaces.
```{eval-rst}
.. currentmodule:: gymnasium.spaces
.. py:currentmodule:: gymnasium.spaces
* :py:class:`Box` - Supports continuous (and discrete) vectors or matrices, used for vector observations, images, etc
* :py:class:`Discrete` - Supports a single discrete number of values with an optional start for the values
* :py:class:`MultiBinary` - Supports single or matrices of binary values, used for holding down a button or if an agent has an object
* :py:class:`MultiDiscrete` - Supports multiple discrete values with multiple axes, used for controller actions
* :py:class:`Text` - Supports strings, used for passing agent messages, mission details, etc
* :class:`Box` - Supports continuous (and discrete) vectors or matrices, used for vector observations, images, etc
* :class:`Discrete` - Supports a single discrete number of values with an optional start for the values
* :class:`MultiBinary` - Supports single or matrices of binary values, used for holding down a button or if an agent has an object
* :class:`MultiDiscrete` - Supports multiple discrete values with multiple axes, used for controller actions
* :class:`Text` - Supports strings, used for passing agent messages, mission details, etc
```
## Composite Spaces
@@ -63,37 +62,41 @@ Gymnasium has a number of fundamental spaces that are used as building boxes for
Often environment spaces require joining fundamental spaces together for vectorised environments, separate agents or readability of the space.
```{eval-rst}
* :py:class:`Dict` - Supports a dictionary of keys and subspaces, used for a fixed number of unordered spaces
* :py:class:`Tuple` - Supports a tuple of subspaces, used for multiple for a fixed number of ordered spaces
* :py:class:`Sequence` - Supports a variable number of instances of a single subspace, used for entities spaces or selecting a variable number of actions
.. py:currentmodule:: gymnasium.spaces
* :class:`Dict` - Supports a dictionary of keys and subspaces, used for a fixed number of unordered spaces
* :class:`Tuple` - Supports a tuple of subspaces, used for multiple for a fixed number of ordered spaces
* :class:`Sequence` - Supports a variable number of instances of a single subspace, used for entities spaces or selecting a variable number of actions
* :py:class:`Graph` - Supports graph based actions or observations with discrete or continuous nodes and edge values.
```
## Utils
## Utility functions
Gymnasium contains a number of helpful utility functions for flattening and unflattening spaces.
This can be important for passing information to neural networks.
```{eval-rst}
* :py:class:`utils.flatdim` - The number of dimensions the flattened space will contain
* :py:class:`utils.flatten_space` - Flattens a space for which the `flattened` space instances will contain
* :py:class:`utils.flatten` - Flattens an instance of a space that is contained within the flattened version of the space
* :py:class:`utils.unflatten` - The reverse of the `flatten_space` function
.. py:currentmodule:: gymnasium.spaces
* :class:`utils.flatdim` - The number of dimensions the flattened space will contain
* :class:`utils.flatten_space` - Flattens a space for which the :class:`utils.flattened` space instances will contain
* :class:`utils.flatten` - Flattens an instance of a space that is contained within the flattened version of the space
* :class:`utils.unflatten` - The reverse of the :class:`utils.flatten_space` function
```
## Vector Utils
## Vector Utility functions
When vectorizing environments, it is necessary to modify the observation and action spaces for new batched spaces sizes.
Therefore, Gymnasium provides a number of additional functions used when using a space with a Vector environment.
```{eval-rst}
.. currentmodule:: gymnasium
.. py:currentmodule:: gymnasium
* :py:class:`vector.utils.batch_space`
* :py:class:`vector.utils.concatenate`
* :py:class:`vector.utils.iterate`
* :py:class:`vector.utils.create_empty_array`
* :py:class:`vector.utils.create_shared_memory`
* :py:class:`vector.utils.read_from_shared_memory`
* :py:class:`vector.utils.write_to_shared_memory`
* :class:`vector.utils.batch_space` - Transforms a space into the equivalent space for ``n`` users
* :class:`vector.utils.concatenate` - Concatenates a space's samples into a pre-generated space
* :class:`vector.utils.iterate` - Iterate over the batched space's samples
* :class:`vector.utils.create_empty_array` - Creates an empty sample for an space (generally used with ``concatenate``)
* :class:`vector.utils.create_shared_memory` - Creates a shared memory for asynchronous (multiprocessing) environment
* :class:`vector.utils.read_from_shared_memory` - Reads a shared memory for asynchronous (multiprocessing) environment
* :class:`vector.utils.write_to_shared_memory` - Write to a shared memory for asynchronous (multiprocessing) environment
```

View File

@@ -1,37 +1,24 @@
# Composite Spaces
## Dict
```{eval-rst}
.. autoclass:: gymnasium.spaces.Dict
.. automethod:: gymnasium.spaces.Dict.sample
.. automethod:: gymnasium.spaces.Dict.seed
```
.. automethod:: gymnasium.spaces.Dict.sample
.. automethod:: gymnasium.spaces.Dict.seed
## Tuple
```{eval-rst}
.. autoclass:: gymnasium.spaces.Tuple
.. automethod:: gymnasium.spaces.Tuple.sample
.. automethod:: gymnasium.spaces.Tuple.seed
```
.. automethod:: gymnasium.spaces.Tuple.sample
.. automethod:: gymnasium.spaces.Tuple.seed
## Sequence
```{eval-rst}
.. autoclass:: gymnasium.spaces.Sequence
.. automethod:: gymnasium.spaces.Sequence.sample
.. automethod:: gymnasium.spaces.Sequence.seed
```
.. automethod:: gymnasium.spaces.Sequence.sample
.. automethod:: gymnasium.spaces.Sequence.seed
## Graph
```{eval-rst}
.. autoclass:: gymnasium.spaces.Graph
.. automethod:: gymnasium.spaces.Graph.sample
.. automethod:: gymnasium.spaces.Graph.seed
.. automethod:: gymnasium.spaces.Graph.sample
.. automethod:: gymnasium.spaces.Graph.seed
```

View File

@@ -4,46 +4,30 @@ title: Fundamental Spaces
# Fundamental Spaces
## Box
```{eval-rst}
.. autoclass:: gymnasium.spaces.Box
.. automethod:: gymnasium.spaces.Box.sample
.. automethod:: gymnasium.spaces.Box.seed
.. automethod:: gymnasium.spaces.Box.is_bounded
```
.. automethod:: gymnasium.spaces.Box.sample
.. automethod:: gymnasium.spaces.Box.seed
.. automethod:: gymnasium.spaces.Box.is_bounded
## Discrete
```{eval-rst}
.. autoclass:: gymnasium.spaces.Discrete
.. automethod:: gymnasium.spaces.Discrete.sample
.. automethod:: gymnasium.spaces.Discrete.seed
```
## MultiBinary
.. automethod:: gymnasium.spaces.Discrete.sample
.. automethod:: gymnasium.spaces.Discrete.seed
```{eval-rst}
.. autoclass:: gymnasium.spaces.MultiBinary
.. automethod:: gymnasium.spaces.MultiBinary.sample
.. automethod:: gymnasium.spaces.MultiBinary.seed
```
## MultiDiscrete
.. automethod:: gymnasium.spaces.MultiBinary.sample
.. automethod:: gymnasium.spaces.MultiBinary.seed
```{eval-rst}
.. autoclass:: gymnasium.spaces.MultiDiscrete
.. automethod:: gymnasium.spaces.MultiDiscrete.sample
.. automethod:: gymnasium.spaces.MultiDiscrete.seed
```
.. automethod:: gymnasium.spaces.MultiDiscrete.sample
.. automethod:: gymnasium.spaces.MultiDiscrete.seed
## Text
```{eval-rst}
.. autoclass:: gymnasium.spaces.Text
.. automethod:: gymnasium.spaces.Text.sample
.. automethod:: gymnasium.spaces.Text.seed
.. automethod:: gymnasium.spaces.Text.sample
.. automethod:: gymnasium.spaces.Text.seed
```

View File

@@ -1,8 +1,20 @@
---
title: Utils
title: Utility functions
---
# Utils
# Utility functions
## Seeding
```{eval-rst}
.. autofunction:: gymnasium.utils.seeding.np_random
```
## Environment Checking
```{eval-rst}
.. autofunction:: gymnasium.utils.env_checker.check_env
```
## Visualization
@@ -17,6 +29,12 @@ title: Utils
.. automethod:: process_event
```
## Environment pickling
```{eval-rst}
.. autoclass:: gymnasium.utils.ezpickle.EzPickle
```
## Save Rendering Videos
```{eval-rst}
@@ -31,15 +49,3 @@ title: Utils
.. autofunction:: gymnasium.utils.step_api_compatibility.convert_to_terminated_truncated_step_api
.. autofunction:: gymnasium.utils.step_api_compatibility.convert_to_done_step_api
```
## Seeding
```{eval-rst}
.. autofunction:: gymnasium.utils.seeding.np_random
```
## Environment Checking
```{eval-rst}
.. autofunction:: gymnasium.utils.env_checker.check_env
```

View File

@@ -2,7 +2,15 @@
title: Vector
---
# Vector
# Vector environments
```{toctree}
:hidden:
vector/wrappers
vector/async_vector_env
vector/sync_vector_env
vector/utils
```
## Gymnasium.vector.VectorEnv
@@ -14,62 +22,47 @@ title: Vector
```{eval-rst}
.. automethod:: gymnasium.vector.VectorEnv.reset
.. automethod:: gymnasium.vector.VectorEnv.step
.. automethod:: gymnasium.vector.VectorEnv.close
```
### Attributes
```{eval-rst}
.. attribute:: action_space
.. autoattribute:: gymnasium.vector.VectorEnv.num_envs
The (batched) action space. The input actions of `step` must be valid elements of `action_space`.::
The number of sub-environments in the vector environment.
>>> envs = gymnasium.vector.make("CartPole-v1", num_envs=3)
>>> envs.action_space
MultiDiscrete([2 2 2])
.. autoattribute:: gymnasium.vector.VectorEnv.action_space
.. attribute:: observation_space
The (batched) action space. The input actions of `step` must be valid elements of `action_space`.
The (batched) observation space. The observations returned by `reset` and `step` are valid elements of `observation_space`.::
.. autoattribute:: gymnasium.vector.VectorEnv.observation_space
>>> envs = gymnasium.vector.make("CartPole-v1", num_envs=3)
>>> envs.observation_space
Box([[-4.8 ...]], [[4.8 ...]], (3, 4), float32)
The (batched) observation space. The observations returned by `reset` and `step` are valid elements of `observation_space`.
.. attribute:: single_action_space
.. autoattribute:: gymnasium.vector.VectorEnv.single_action_space
The action space of an environment copy.::
The action space of a sub-environment.
>>> envs = gymnasium.vector.make("CartPole-v1", num_envs=3)
>>> envs.single_action_space
Discrete(2)
.. autoattribute:: gymnasium.vector.VectorEnv.single_observation_space
.. attribute:: single_observation_space
The observation space of an environment copy.
The observation space of an environment copy.::
.. autoattribute:: gymnasium.vector.VectorEnv.spec
>>> envs = gymnasium.vector.make("CartPole-v1", num_envs=3)
>>> envs.single_observation_space
Box([-4.8 ...], [4.8 ...], (4,), float32)
The ``EnvSpec`` of the environment normally set during :py:meth:`gymnasium.make_vec`
```
### Additional Methods
```{eval-rst}
.. autoproperty:: gymnasium.vector.VectorEnv.unwrapped
.. autoproperty:: gymnasium.vector.VectorEnv.np_random
```
## Making Vector Environments
```{eval-rst}
.. autofunction:: gymnasium.vector.make
```
## Async Vector Env
```{eval-rst}
.. autoclass:: gymnasium.vector.AsyncVectorEnv
```
## Sync Vector Env
```{eval-rst}
.. autoclass:: gymnasium.vector.SyncVectorEnv
To create vector environments, gymnasium provides :func:`gymnasium.make_vec` as an equivalent function to :func:`gymnasium.make`.
```

View File

@@ -0,0 +1,13 @@
# AsyncVectorEnv
```{eval-rst}
.. autoclass:: gymnasium.vector.AsyncVectorEnv
.. automethod:: gymnasium.vector.AsyncVectorEnv.reset
.. automethod:: gymnasium.vector.AsyncVectorEnv.step
.. automethod:: gymnasium.vector.AsyncVectorEnv.close
.. automethod:: gymnasium.vector.AsyncVectorEnv.call
.. automethod:: gymnasium.vector.AsyncVectorEnv.get_attr
.. automethod:: gymnasium.vector.AsyncVectorEnv.set_attr
```

View File

@@ -0,0 +1,13 @@
# SyncVectorEnv
```{eval-rst}
.. autoclass:: gymnasium.vector.SyncVectorEnv
.. automethod:: gymnasium.vector.SyncVectorEnv.reset
.. automethod:: gymnasium.vector.SyncVectorEnv.step
.. automethod:: gymnasium.vector.SyncVectorEnv.close
.. automethod:: gymnasium.vector.SyncVectorEnv.call
.. automethod:: gymnasium.vector.SyncVectorEnv.get_attr
.. automethod:: gymnasium.vector.SyncVectorEnv.set_attr
```

View File

@@ -1,20 +1,25 @@
---
title: Vector Utils
---
# Utility functions
# Spaces Vector Utils
## Vectorizing Spaces
```{eval-rst}
.. autofunction:: gymnasium.vector.utils.batch_space
.. autofunction:: gymnasium.vector.utils.concatenate
.. autofunction:: gymnasium.vector.utils.iterate
.. autofunction:: gymnasium.vector.utils.create_empty_array
```
## Shared Memory Utils
## Shared Memory for a Space
```{eval-rst}
.. autofunction:: gymnasium.vector.utils.create_empty_array
.. autofunction:: gymnasium.vector.utils.create_shared_memory
.. autofunction:: gymnasium.vector.utils.read_from_shared_memory
.. autofunction:: gymnasium.vector.utils.write_to_shared_memory
```
## Miscellaneous
```{eval-rst}
.. autofunction:: gymnasium.vector.utils.CloudpickleWrapper
.. autofunction:: gymnasium.vector.utils.clear_mpi_env_vars
```

View File

@@ -0,0 +1,26 @@
---
title: Vector Wrappers
---
# Vector Wrappers
```{eval-rst}
.. autoclass:: gymnasium.vector.VectorWrapper
.. automethod:: gymnasium.vector.VectorWrapper.step
.. automethod:: gymnasium.vector.VectorWrapper.reset
.. automethod:: gymnasium.vector.VectorWrapper.close
.. autoclass:: gymnasium.vector.VectorObservationWrapper
.. automethod:: gymnasium.vector.VectorObservationWrapper.vector_observation
.. automethod:: gymnasium.vector.VectorObservationWrapper.single_observation
.. autoclass:: gymnasium.vector.VectorActionWrapper
.. automethod:: gymnasium.vector.VectorActionWrapper.actions
.. autoclass:: gymnasium.vector.VectorRewardWrapper
.. automethod:: gymnasium.vector.VectorRewardWrapper.rewards
```

View File

@@ -6,134 +6,47 @@ title: Wrapper
```{toctree}
:hidden:
wrappers/table
wrappers/misc_wrappers
wrappers/action_wrappers
wrappers/observation_wrappers
wrappers/reward_wrappers
wrappers/vector_wrappers
```
```{eval-rst}
.. automodule:: gymnasium.wrappers
```
## gymnasium.Wrapper
```{eval-rst}
.. autoclass:: gymnasium.Wrapper
```
### Methods
## Methods
```{eval-rst}
.. autofunction:: gymnasium.Wrapper.step
.. autofunction:: gymnasium.Wrapper.reset
.. autofunction:: gymnasium.Wrapper.close
.. automethod:: gymnasium.Wrapper.step
.. automethod:: gymnasium.Wrapper.reset
.. automethod:: gymnasium.Wrapper.render
.. automethod:: gymnasium.Wrapper.close
.. automethod:: gymnasium.Wrapper.wrapper_spec
.. automethod:: gymnasium.Wrapper.get_wrapper_attr
.. automethod:: gymnasium.Wrapper.set_wrapper_attr
```
### Attributes
## Attributes
```{eval-rst}
.. autoproperty:: gymnasium.Wrapper.action_space
.. autoproperty:: gymnasium.Wrapper.observation_space
.. autoproperty:: gymnasium.Wrapper.reward_range
.. autoproperty:: gymnasium.Wrapper.spec
.. autoproperty:: gymnasium.Wrapper.metadata
.. autoproperty:: gymnasium.Wrapper.np_random
.. attribute:: gymnasium.Wrapper.env
.. autoattribute:: gymnasium.Wrapper.env
The environment (one level underneath) this wrapper.
This may itself be a wrapped environment.
To obtain the environment underneath all layers of wrappers, use :attr:`gymnasium.Wrapper.unwrapped`.
This may itself be a wrapped environment. To obtain the environment underneath all layers of wrappers, use :attr:`gymnasium.Wrapper.unwrapped`.
.. autoproperty:: gymnasium.Wrapper.action_space
.. autoproperty:: gymnasium.Wrapper.observation_space
.. autoproperty:: gymnasium.Wrapper.spec
.. autoproperty:: gymnasium.Wrapper.metadata
.. autoproperty:: gymnasium.Wrapper.np_random
.. autoproperty:: gymnasium.Wrapper.unwrapped
```
## Gymnasium 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
```{eval-rst}
.. py:currentmodule:: gymnasium.wrappers
.. list-table::
:header-rows: 1
* - Name
- Type
- Description
* - :class:`AtariPreprocessing`
- Misc Wrapper
- Implements the common preprocessing applied to Atari environments
* - :class:`AutoResetWrapper`
- Misc Wrapper
- The wrapped environment will automatically reset when the terminated or truncated state is reached.
* - :class:`ClipAction`
- Action Wrapper
- Clip the continuous action to the valid bound specified by the environment's `action_space`
* - :class:`EnvCompatibility`
- Misc Wrapper
- Provides compatibility for environments written in the OpenAI Gym v0.21 API to look like Gymnasium environments
* - :class:`FilterObservation`
- Observation Wrapper
- Filters a dictionary observation spaces to only requested keys
* - :class:`FlattenObservation`
- Observation Wrapper
- An Observation wrapper that flattens the observation
* - :class:`FrameStack`
- Observation Wrapper
- AnObservation wrapper that stacks the observations in a rolling manner.
* - :class:`GrayScaleObservation`
- Observation Wrapper
- Convert the image observation from RGB to gray scale.
* - :class:`HumanRendering`
- Misc Wrapper
- Allows human like rendering for environments that support "rgb_array" rendering
* - :class:`NormalizeObservation`
- Observation Wrapper
- This wrapper will normalize observations s.t. each coordinate is centered with unit variance.
* - :class:`NormalizeReward`
- Reward Wrapper
- This wrapper will normalize immediate rewards s.t. their exponential moving average has a fixed variance.
* - :class:`OrderEnforcing`
- Misc Wrapper
- This will produce an error if `step` or `render` is called before `reset`
* - :class:`PixelObservationWrapper`
- Observation Wrapper
- Augment observations by pixel values obtained via `render` that can be added to or replaces the environments observation.
* - :class:`RecordEpisodeStatistics`
- Misc Wrapper
- This will keep track of cumulative rewards and episode lengths returning them at the end.
* - :class:`RecordVideo`
- Misc Wrapper
- This wrapper will record videos of rollouts.
* - :class:`RenderCollection`
- Misc Wrapper
- Enable list versions of render modes, i.e. "rgb_array_list" for "rgb_array" such that the rendering for each step are saved in a list until `render` is called.
* - :class:`RescaleAction`
- Action Wrapper
- Rescales the continuous action space of the environment to a range \[`min_action`, `max_action`], where `min_action` and `max_action` are numpy arrays or floats.
* - :class:`ResizeObservation`
- Observation Wrapper
- This wrapper works on environments with image observations (or more generally observations of shape AxBxC) and resizes the observation to the shape given by the tuple `shape`.
* - :class:`StepAPICompatibility`
- Misc Wrapper
- Modifies an environment step function from (old) done to the (new) termination / truncation API.
* - :class:`TimeAwareObservation`
- Observation Wrapper
- Augment the observation with current time step in the trajectory (by appending it to the observation).
* - :class:`TimeLimit`
- Misc Wrapper
- This wrapper will emit a truncated signal if the specified number of steps is exceeded in an episode.
* - :class:`TransformObservation`
- Observation Wrapper
- This wrapper will apply function to observations
* - :class:`TransformReward`
- Reward Wrapper
- This wrapper will apply function to rewards
* - :class:`VectorListInfo`
- Misc Wrapper
- This wrapper will convert the info of a vectorized environment from the `dict` format to a `list` of dictionaries where the i-th dictionary contains info of the i-th environment.
```

View File

@@ -5,12 +5,14 @@
```{eval-rst}
.. autoclass:: gymnasium.ActionWrapper
.. automethod:: gymnasium.ActionWrapper.action
.. automethod:: gymnasium.ActionWrapper.action
```
## Available Action Wrappers
```{eval-rst}
.. autoclass:: gymnasium.wrappers.TransformAction
.. autoclass:: gymnasium.wrappers.ClipAction
.. autoclass:: gymnasium.wrappers.RescaleAction
.. autoclass:: gymnasium.wrappers.StickyAction
```

View File

@@ -1,16 +1,33 @@
---
title: Misc Wrappers
---
# Misc Wrappers
## Common Wrappers
```{eval-rst}
.. autoclass:: gymnasium.wrappers.TimeLimit
.. autoclass:: gymnasium.wrappers.RecordVideo
.. autoclass:: gymnasium.wrappers.RecordEpisodeStatistics
.. autoclass:: gymnasium.wrappers.AtariPreprocessing
.. autoclass:: gymnasium.wrappers.AutoResetWrapper
.. autoclass:: gymnasium.wrappers.EnvCompatibility
.. autoclass:: gymnasium.wrappers.StepAPICompatibility
```
## Uncommon Wrappers
```{eval-rst}
.. autoclass:: gymnasium.wrappers.Autoreset
.. autoclass:: gymnasium.wrappers.PassiveEnvChecker
.. autoclass:: gymnasium.wrappers.HumanRendering
.. autoclass:: gymnasium.wrappers.OrderEnforcing
.. autoclass:: gymnasium.wrappers.RecordEpisodeStatistics
.. autoclass:: gymnasium.wrappers.RecordVideo
.. autoclass:: gymnasium.wrappers.RenderCollection
.. autoclass:: gymnasium.wrappers.TimeLimit
.. autoclass:: gymnasium.wrappers.VectorListInfo
```
## Data Conversion Wrappers
```{eval-rst}
.. autoclass:: gymnasium.wrappers.JaxToNumpy
.. autoclass:: gymnasium.wrappers.JaxToTorch
.. autoclass:: gymnasium.wrappers.NumpyToTorch
```

View File

@@ -1,23 +1,26 @@
# Observation Wrappers
## Base Class
```{eval-rst}
.. autoclass:: gymnasium.ObservationWrapper
.. automethod:: gymnasium.ObservationWrapper.observation
```
## Available Observation Wrappers
## Implemented Wrappers
```{eval-rst}
.. autoclass:: gymnasium.wrappers.TransformObservation
.. autoclass:: gymnasium.wrappers.DelayObservation
.. autoclass:: gymnasium.wrappers.DtypeObservation
.. autoclass:: gymnasium.wrappers.FilterObservation
.. autoclass:: gymnasium.wrappers.FlattenObservation
.. autoclass:: gymnasium.wrappers.FrameStack
.. autoclass:: gymnasium.wrappers.GrayScaleObservation
.. autoclass:: gymnasium.wrappers.FrameStackObservation
.. autoclass:: gymnasium.wrappers.GrayscaleObservation
.. autoclass:: gymnasium.wrappers.MaxAndSkipObservation
.. autoclass:: gymnasium.wrappers.NormalizeObservation
.. autoclass:: gymnasium.wrappers.PixelObservationWrapper
.. autoclass:: gymnasium.wrappers.RenderObservation
.. autoclass:: gymnasium.wrappers.ResizeObservation
.. autoclass:: gymnasium.wrappers.ReshapeObservation
.. autoclass:: gymnasium.wrappers.RescaleObservation
.. autoclass:: gymnasium.wrappers.TimeAwareObservation
```

View File

@@ -1,17 +1,19 @@
---
title: Reward Wrappers
---
# Reward Wrappers
## Base Class
```{eval-rst}
.. autoclass:: gymnasium.RewardWrapper
.. automethod:: gymnasium.RewardWrapper.reward
```
## Available Reward Wrappers
## Implemented Wrappers
```{eval-rst}
.. autoclass:: gymnasium.wrappers.TransformReward
.. autoclass:: gymnasium.wrappers.NormalizeReward
.. autoclass:: gymnasium.wrappers.ClipReward
```

102
docs/api/wrappers/table.md Normal file
View File

@@ -0,0 +1,102 @@
# 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
```{eval-rst}
.. py:currentmodule:: gymnasium.wrappers
.. list-table::
:header-rows: 1
* - Name
- Description
* - :class:`AtariPreprocessing`
- Implements the common preprocessing techniques for Atari environments (excluding frame stacking).
* - :class:`Autoreset`
- The wrapped environment is automatically reset when an terminated or truncated state is reached.
* - :class:`ClipAction`
- Clips the ``action`` pass to ``step`` to be within the environment's `action_space`.
* - :class:`ClipReward`
- Clips the rewards for an environment between an upper and lower bound.
* - :class:`DelayObservation`
- Adds a delay to the returned observation from the environment.
* - :class:`DtypeObservation`
- Modifies the dtype of an observation array to a specified dtype.
* - :class:`FilterObservation`
- Filters a Dict or Tuple observation spaces by a set of keys or indexes.
* - :class:`FlattenObservation`
- Flattens the environment's observation space and each observation from ``reset`` and ``step`` functions.
* - :class:`FrameStackObservation`
- Stacks the observations from the last ``N`` time steps in a rolling manner.
* - :class:`GrayscaleObservation`
- Converts an image observation computed by ``reset`` and ``step`` from RGB to Grayscale.
* - :class:`HumanRendering`
- Allows human like rendering for environments that support "rgb_array" rendering.
* - :class:`JaxToNumpy`
- Wraps a Jax-based environment such that it can be interacted with NumPy arrays.
* - :class:`JaxToTorch`
- Wraps a Jax-based environment so that it can be interacted with PyTorch Tensors.
* - :class:`MaxAndSkipObservation`
- Skips the N-th frame (observation) and return the max values between the two last observations.
* - :class:`NormalizeObservation`
- Normalizes observations to be centered at the mean with unit variance.
* - :class:`NormalizeReward`
- Normalizes immediate rewards such that their exponential moving average has a fixed variance.
* - :class:`NumpyToTorch`
- Wraps a NumPy-based environment such that it can be interacted with PyTorch Tensors.
* - :class:`OrderEnforcing`
- Will produce an error if ``step`` or ``render`` is called before ``render``.
* - :class:`PassiveEnvChecker`
- A passive environment checker wrapper that surrounds the ``step``, ``reset`` and ``render`` functions to check they follows gymnasium's API.
* - :class:`RecordEpisodeStatistics`
- This wrapper will keep track of cumulative rewards and episode lengths.
* - :class:`RecordVideo`
- Records videos of environment episodes using the environment's render function.
* - :class:`RenderCollection`
- Collect rendered frames of an environment such ``render`` returns a ``list[RenderedFrame]``.
* - :class:`RenderObservation`
- Includes the rendered observations in the environment's observations.
* - :class:`RescaleAction`
- Affinely (linearly) rescales a ``Box`` action space of the environment to within the range of ``[min_action, max_action]``.
* - :class:`RescaleObservation`
- Affinely (linearly) rescales a ``Box`` observation space of the environment to within the range of ``[min_obs, max_obs]``.
* - :class:`ReshapeObservation`
- Reshapes Array based observations to a specified shape.
* - :class:`ResizeObservation`
- Resizes image observations using OpenCV to a specified shape.
* - :class:`StickyAction`
- Adds a probability that the action is repeated for the same ``step`` function.
* - :class:`TimeAwareObservation`
- Augment the observation with the number of time steps taken within an episode.
* - :class:`TimeLimit`
- Limits the number of steps for an environment through truncating the environment if a maximum number of timesteps is exceeded.
* - :class:`TransformAction`
- Applies a function to the ``action`` before passing the modified value to the environment ``step`` function.
* - :class:`TransformObservation`
- Applies a function to the ``observation`` received from the environment's ``reset`` and ``step`` that is passed back to the user.
* - :class:`TransformReward`
- Applies a function to the ``reward`` received from the environment's ``step``.
```
## Vector only Wrappers
```{eval-rst}
.. py:currentmodule:: gymnasium.wrappers.vector
.. list-table::
:header-rows: 1
* - Name
- Description
* - :class:`DictInfoToList`
- Converts infos of vectorized environments from ``dict`` to ``List[dict]``.
* - :class:`VectorizeTransformAction`
- Vectorizes a single-agent transform action wrapper for vector environments.
* - :class:`VectorizeTransformObservation`
- Vectorizes a single-agent transform observation wrapper for vector environments.
* - :class:`VectorizeTransformReward`
- Vectorizes a single-agent transform reward wrapper for vector environments.
```

View File

@@ -0,0 +1,19 @@
---
title: Vector Wrappers
---
# Vector wrappers
## Vector only wrappers
```{eval-rst}
.. autoclass:: gymnasium.wrappers.vector.DictInfoToList
```
## Vectorize Transform Wrappers to Vector Wrappers
```{eval-rst}
.. autoclass:: gymnasium.wrappers.vector.VectorizeTransformObservation
.. autoclass:: gymnasium.wrappers.vector.VectorizeTransformAction
.. autoclass:: gymnasium.wrappers.vector.VectorizeTransformReward
```