Table of Contents

Interface IVectorEnv

Namespace
Gym.Vector
Assembly
Gym.dll

A vector env seen without its types (DR-21): what registry-wide code, the untyped MakeVec and tools that handle any vector env work with. Observations, actions and spaces are objects and untyped Spaces; the rewards and flags are arrays either way. VectorEnv<TObs, TAct> implements it.

public interface IVectorEnv : IDisposable
Inherited Members
Extension Methods

Remarks

A vector env runs NumEnvs copies of an env in lockstep: every step takes one action per sub-env (batched by ActionSpace) and returns every sub-env's result batched along the first axis. When a sub-env's episode ends, the env's metadata["autoreset_mode"] (AutoresetMode) says when it is reset. Reference: gymnasium/vector/vector_env.py.

Properties

ActionSpace

The batched action space (action_space), whose samples are one action per sub-env.

Space ActionSpace { get; set; }

Property Value

Space

Exceptions

AttributeError

Thrown by the getter while unset.

Closed

Whether Close() ran (closed); a second close does nothing.

bool Closed { get; set; }

Property Value

bool

Metadata

The metadata (metadata): the render modes and frame rate, and autoreset_mode.

Metadata Metadata { get; set; }

Property Value

Metadata

NpRandom

The vector env's own generator (np_random), created from OS entropy on first read; the sub-envs have theirs. Only vector envs that draw themselves (CartPoleVectorEnv) use it.

Generator NpRandom { get; set; }

Property Value

Generator

NpRandomSeed

The seed of NpRandom (np_random_seed); -1 after a generator was assigned.

BigInteger NpRandomSeed { get; }

Property Value

BigInteger

NumEnvs

The number of sub-envs (num_envs), fixed at construction.

int NumEnvs { get; }

Property Value

int

ObservationSpace

The batched observation space (observation_space): the single space batched NumEnvs times.

Space ObservationSpace { get; set; }

Property Value

Space

Exceptions

AttributeError

Thrown by the getter while unset.

RenderMode

The sub-envs' render mode (render_mode), or null.

string? RenderMode { get; }

Property Value

string

SingleActionSpace

One sub-env's action space (single_action_space).

Space SingleActionSpace { get; set; }

Property Value

Space

Exceptions

AttributeError

Thrown by the getter while unset.

SingleObservationSpace

One sub-env's observation space (single_observation_space).

Space SingleObservationSpace { get; set; }

Property Value

Space

Exceptions

AttributeError

Thrown by the getter while unset.

Spec

The spec MakeVec attached (spec), or null for a vector env built with its constructor.

EnvSpec? Spec { get; set; }

Property Value

EnvSpec

Unwrapped

The innermost vector env under any vector wrappers (unwrapped).

IVectorEnv Unwrapped { get; }

Property Value

IVectorEnv

Methods

Close()

Closes the vector env and its sub-envs (close()); a second call does nothing.

void Close()

Render()

Renders every sub-env (render()): one result each, or null where Python returns None.

IReadOnlyList<RenderResult>? Render()

Returns

IReadOnlyList<RenderResult>

The frames or texts, in sub-env order, or null.

Reset(IReadOnlyList<BigInteger?>, IReadOnlyDictionary<string, object?>?)

Resets every sub-env with a seed each (reset(seed=[...])), null keeping a sub-env's generator.

VectorResetResult<object?> Reset(IReadOnlyList<BigInteger?> seeds, IReadOnlyDictionary<string, object?>? options = null)

Parameters

seeds IReadOnlyList<BigInteger?>

One seed per sub-env.

options IReadOnlyDictionary<string, object>

The reset options, as for Reset(BigInteger?, IReadOnlyDictionary<string, object?>?).

Returns

VectorResetResult<object>

The batched observations and merged infos.

Reset(BigInteger?, IReadOnlyDictionary<string, object?>?)

Resets every sub-env (reset(seed=seed, options=options)); an integer seed seeds sub-env i with seed + i.

VectorResetResult<object?> Reset(BigInteger? seed = null, IReadOnlyDictionary<string, object?>? options = null)

Parameters

seed BigInteger?

The seed, or null to keep the generators.

options IReadOnlyDictionary<string, object>

The reset options, passed to every sub-env; reset_mask picks which sub-envs reset.

Returns

VectorResetResult<object>

The batched observations and merged infos.

Step(object?)

Steps every sub-env with its action (step(actions)).

VectorStepResult<object?> Step(object? actions)

Parameters

actions object

One action per sub-env, as the batched action space samples them.

Returns

VectorStepResult<object>

The batched transition.