Skip to content

Commit e2599f0

Browse files
Update vector autoreset documentation. (#1318)
1 parent e4c1f90 commit e2599f0

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

gymnasium/vector/async_vector_env.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def __init__(
121121
'different' defines that there can be multiple observation spaces with different parameters though requires the same shape and dtype,
122122
warning, may raise unexpected errors. Passing a ``Tuple[Space, Space]`` object allows defining a custom ``single_observation_space`` and
123123
``observation_space``, warning, may raise unexpected errors.
124-
autoreset_mode: The Autoreset Mode used, see todo for more details.
124+
autoreset_mode: The Autoreset Mode used, see https://farama.org/Vector-Autoreset-Mode for more information.
125125
126126
Warnings:
127127
worker is an advanced mode option. It provides a high degree of flexibility and a high chance

gymnasium/vector/sync_vector_env.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def __init__(
7575
observation_mode: Defines how environment observation spaces should be batched. 'same' defines that there should be ``n`` copies of identical spaces.
7676
'different' defines that there can be multiple observation spaces with the same length but different high/low values batched together. Passing a ``Space`` object
7777
allows the user to set some custom observation space mode not covered by 'same' or 'different.'
78-
autoreset_mode: The Autoreset Mode used, see todo for more details.
78+
autoreset_mode: The Autoreset Mode used, see https://farama.org/Vector-Autoreset-Mode for more information.
7979
8080
Raises:
8181
RuntimeError: If the observation space of some sub-environment does not match observation_space

gymnasium/vector/vector_env.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ class VectorEnv(Generic[ObsType, ActType, ArrayType]):
5454
vector environments that contains several unique arguments for modifying environment qualities, number of environment,
5555
vectorizer type, vectorizer arguments.
5656
57+
To avoid having to wait for all sub-environments to terminated before resetting, implementations can autoreset
58+
sub-environments on episode end (`terminated or truncated is True`). This is crucial for correct implementing training
59+
algorithms with vector environments. By default, Gymnasium's implementation uses `next-step` autoreset, with
60+
:class:`AutoresetMode` enum as the options. The mode used by vector environment should be available in `metadata["autoreset_mode"]`.
61+
Warning, some vector implementations or training algorithms will only support particular autoreset modes.
62+
For more information, read https://farama.org/Vector-Autoreset-Mode.
63+
5764
Note:
5865
The info parameter of :meth:`reset` and :meth:`step` was originally implemented before v0.25 as a list
5966
of dictionary for each sub-environment. However, this was modified in v0.25+ to be a dictionary with a NumPy
@@ -102,12 +109,6 @@ class VectorEnv(Generic[ObsType, ActType, ArrayType]):
102109
{}
103110
>>> envs.close()
104111
105-
To avoid having to wait for all sub-environments to terminated before resetting, implementations will autoreset
106-
sub-environments on episode end (`terminated or truncated is True`). As a result, when adding observations
107-
to a replay buffer, this requires knowing when an observation (and info) for each sub-environment are the first
108-
observation from an autoreset. We recommend using an additional variable to store this information such as
109-
``has_autoreset = np.logical_or(terminated, truncated)``.
110-
111112
The Vector Environments have the additional attributes for users to understand the implementation
112113
113114
- :attr:`num_envs` - The number of sub-environment in the vector environment

0 commit comments

Comments
 (0)