From f2e28b8f3a10c34c4803965101ca382c1ea3bc6e Mon Sep 17 00:00:00 2001 From: Tim Schneider Date: Wed, 10 Apr 2024 14:53:35 +0200 Subject: [PATCH] Added metadata field to VectorEnv. Implements #1005 --- gymnasium/vector/vector_env.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gymnasium/vector/vector_env.py b/gymnasium/vector/vector_env.py index 7127dd9aa..271603a9a 100644 --- a/gymnasium/vector/vector_env.py +++ b/gymnasium/vector/vector_env.py @@ -92,6 +92,9 @@ class VectorEnv(Generic[ObsType, ActType, ArrayType]): :func:`make_vec` is the equivalent function to :func:`make` for vector environments. """ + # Set this in SOME subclasses + metadata: dict[str, Any] = {"render_modes": []} + spec: EnvSpec | None = None render_mode: str | None = None closed: bool = False @@ -446,6 +449,11 @@ def render_mode(self) -> tuple[RenderFrame, ...] | None: """Returns the `render_mode` from the base environment.""" return self.env.render_mode + @property + def metadata(self) -> dict[str, Any]: + """Returns the `metadata` from the base environment.""" + return self.env.metadata + @property def np_random(self) -> np.random.Generator: """Returns the environment's internal :attr:`_np_random` that if not set will initialise with a random seed.