You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Depending on the type of seed, the subspaces will be seeded differently
54
54
55
55
* ``None`` - All the subspaces will use a random initial seed
56
56
* ``Int`` - The integer is used to seed the :class:`Tuple` space that is used to generate seed values for each of the subspaces. Warning, this does not guarantee unique seeds for all the subspaces.
57
-
* ``List`` - Values used to seed the subspaces. This allows the seeding of multiple composite subspaces ``[42, 54, ...]``.
57
+
* ``List`` / ``Tuple`` - Values used to seed the subspaces. This allows the seeding of multiple composite subspaces ``[42, 54, ...]``.
58
58
59
59
Args:
60
60
seed: An optional list of ints or int to seed the (sub-)spaces.
worker: If set, then use that worker in a subprocess instead of a default one.
120
118
Can be useful to override some inner vector env logic, for instance, how resets on termination or truncation are handled.
121
119
observation_mode: Defines how environment observation spaces should be batched. 'same' defines that there should be ``n`` copies of identical spaces.
122
-
'different' defines that there can be multiple observation spaces with the same length but different high/low values batched together. Passing a ``Space`` object
123
-
allows the user to set some custom observation space mode not covered by 'same' or 'different.'
120
+
'different' defines that there can be multiple observation spaces with different parameters though requires the same shape and dtype,
121
+
warning, may raise unexpected errors. Passing a ``Tuple[Space, Space]`` object allows defining a custom ``single_observation_space`` and
122
+
``observation_space``, warning, may raise unexpected errors.
124
123
125
124
Warnings:
126
125
worker is an advanced mode option. It provides a high degree of flexibility and a high chance
127
126
to shoot yourself in the foot; thus, if you are writing your own worker, it is recommended to start
128
-
from the code for ``_worker`` (or ``_worker_shared_memory``) method, and add changes.
127
+
from the code for ``_worker`` (or ``_async_worker``) method, and add changes.
129
128
130
129
Raises:
131
130
RuntimeError: If the observation space of some sub-environment does not match observation_space
f"Invalid `observation_mode`, expected: 'same' or 'different' or tuple of single and batch observation space, actual got {observation_mode}"
173
+
)
174
174
175
175
dummy_env.close()
176
176
deldummy_env
@@ -187,9 +187,7 @@ def __init__(
187
187
)
188
188
exceptCustomSpaceErrorase:
189
189
raiseValueError(
190
-
"Using `shared_memory=True` in `AsyncVectorEnv` is incompatible with non-standard Gymnasium observation spaces (i.e. custom spaces inheriting from `gymnasium.Space`), "
191
-
"and is only compatible with default Gymnasium spaces (e.g. `Box`, `Tuple`, `Dict`) for batching. "
192
-
"Set `shared_memory=False` if you use custom observation spaces."
190
+
"Using `AsyncVector(..., shared_memory=True)` caused an error, you can disable this feature with `shared_memory=False` however this is slower."
f"Some environments have an observation space different from `{self.single_observation_space}`. "
631
-
"In order to batch observations, the observation spaces from all environments must be equal."
632
-
)
635
+
ifself.observation_mode=="same":
636
+
raiseRuntimeError(
637
+
"AsyncVectorEnv(..., observation_mode='same') however some of the sub-environments observation spaces are not equivalent. If this is intentional, use `observation_mode='different'` instead."
638
+
)
639
+
else:
640
+
raiseRuntimeError(
641
+
"AsyncVectorEnv(..., observation_mode='different' or custom space) however the sub-environment's observation spaces do not share a common shape and dtype."
642
+
)
643
+
633
644
ifnotall(same_action_spaces):
634
645
raiseRuntimeError(
635
646
f"Some environments have an action space different from `{self.single_action_space}`. "
0 commit comments