Namespace Gym.Vector
Classes
- AsyncState
Which call an AsyncVectorEnv<TObs, TAct> is waiting on: none (Default), or the
reset,steporcallsent by its_asyncmethod, whose results the matching_waitcollects. Starting another call or waiting on the wrong one fails with AlreadyPendingCallError or NoAsyncCallError, whoseNameis the pending call's Value.
- AsyncVectorEnv
AsyncVectorEnv<TObs, TAct> untyped: observations and actions are objects, whatever the spaces, as Gymnasium's own. The untyped
MakeVec(..., vectorizationMode: "async")builds this one.
- AsyncVectorEnv<TObs, TAct>
A vector env that runs its sub-envs in parallel, each call on a worker thread (Gymnasium's
AsyncVectorEnv, whose workers are processes): the same results as SyncVectorEnv<TObs, TAct> gathered in sub-env order, for envs whose steps are long enough to be worth a thread. Typed by the batched types; AsyncVectorEnv is the untyped one.
- AutoresetModes
Python's view of AutoresetMode's members (DR-84): their
.name,.value,strandrepr, Gymnasium'sAutoresetMode(value)call, and the reading of a vector env'sautoreset_modeargument. A C# enum cannot carry members of its own, so they live here, beside it.
- PipeConnection
One handle on one end of a two-way pipe (DR-38), the counterpart of Python's
multiprocessing.connection.Connection: what AsyncVectorEnv<TObs, TAct> and a custom AsyncVectorWorker talk through. Send(object?) queues a value for the other end, Recv() takes the next value the other end sent, waiting for it, Poll(double?) waits for one without taking it.
- SyncVectorEnv
SyncVectorEnv<TObs, TAct> untyped: observations and actions are objects, whatever the spaces, as Gymnasium's own. The untyped
MakeVecbuilds this one.
- SyncVectorEnv<TObs, TAct>
A vector env that steps its sub-envs one after another on the calling thread: the reference implementation of the vector API, byte for byte what Gymnasium's
SyncVectorEnvreturns for the same sub-envs, seeds and actions. Typed by the batched types (NDArray for array spaces); SyncVectorEnv is the untyped one.
- VectorActionWrapper<TObs, TWAct, TAct>
A vector wrapper that changes only the actions, through Actions(TWAct), before every step.
- VectorEnv<TObs, TAct>
The base of every vector env (DR-21): NumEnvs sub-envs stepped in lockstep, typed by the batched observation and action types (NDArray for array spaces, object?[] for a
Tuplespace, Info for aDictspace). Rewards are a float64 array and the flags bool arrays, one element per sub-env; infos are merged by key with Gymnasium's_keymasks (AddInfo(Info, Info, int)).
- VectorObservationWrapper<TWObs, TObs, TAct>
A vector wrapper that changes only the observations, through Observations(TObs), on reset and on every step. It refuses a
SAME_STEPenv: there the batch mixes new and final observations, which a transform of the batch cannot tell apart.
- VectorRewardWrapper<TObs, TAct>
A vector wrapper that changes only the rewards, through Rewards(NDArray), after every step.
- VectorUtils
Gymnasium's
gymnasium.vector.utilsspace functions: batching a space fornenvs, iterating over and concatenating batched samples, and allocating an empty batch. Vector envs use them for their batched spaces and observations; Graph and a stacked Sequence sample through them.
- VectorWrapper<TObs, TAct>
A vector wrapper of the env's own types (
VectorWrapper[ObsType, ActType]), the base of wrappers that change neither.
- VectorWrapper<TWObs, TWAct, TObs, TAct>
Wraps a vector env to change its behaviour, forwarding everything it does not change: the spaces (until the wrapper assigns its own), the metadata, the spec, the generator, NumEnvs, reset, step, render and close. Typed by the wrapper's batched types and the wrapped env's.
Structs
- AsyncWorkerError
A worker's failure, as Gymnasium's error queue holds it: the worker's index, the exception (rethrown to the vector env's caller as it was thrown) and its text with the stack trace (Python's
traceback.format_exc()).
- VectorResetResult<TObs>
The first observations of every reset sub-env and their merged infos,
(observations, infos). Deconstructs like a tuple:var (obs, infos) = envs.Reset(seed: 42);.
- VectorStepResult<TObs>
One step of every sub-env at once,
(observations, rewards, terminations, truncations, infos), in Gymnasium's vector layout. Deconstructs like a tuple:var (obs, rewards, terminations, truncations, infos) = envs.Step(actions);.
Interfaces
- IVectorEnv
A vector env seen without its types (DR-21): what registry-wide code, the untyped
MakeVecand 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.
Enums
- AsyncExecutionMode
Where an AsyncVectorEnv<TObs, TAct> runs its sub-envs' calls (DR-22). Gymnasium runs each sub-env in its own process; Gym.NET runs them on threads of the calling process, and the mode decides which. Every mode gives the same results, gathered in sub-env order, so the choice is about throughput and thread affinity only.
- AutoresetMode
When a vector env resets a sub-env whose episode ended: on the next step (NextStep, Gymnasium's default), within the same step (SameStep, the ended episode's last observation and info moved into
final_obs/final_info), or never (Disabled, the caller resets throughreset_mask). A vector env states its mode inmetadata["autoreset_mode"], and training code must handle the mode it gets: the same step's observation means different things in each.
Delegates
- AsyncVectorWorker
A function that serves one sub-env of an AsyncVectorEnv<TObs, TAct> (DR-38, Gymnasium's
worker): it builds the sub-env, then answers the parent's commands through its pipe until a close, as Gymnasium's worker process does. AsyncWorker(int, Func<IEnv>, PipeConnection, PipeConnection, object?, ConcurrentQueue<AsyncWorkerError>, AutoresetMode, SemaphoreSlim?) is the default one; a custom worker usually wraps it, changing what it needs.