Struct 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);.
public readonly record struct VectorStepResult<TObs> : INDArrayCarrier, IDisposable, IEquatable<VectorStepResult<TObs>>
Type Parameters
TObsThe batched observation type, an element of the vector env's batched observation space.
- Implements
-
IEquatable<VectorStepResult<TObs>>
- Inherited Members
- Extension Methods
Remarks
Equality is exact: arrays by shape, dtype and elements; the infos by Python's ==. Reference:
gymnasium/vector/vector_env.py (VectorEnv.step).
Constructors
VectorStepResult(TObs, NDArray, NDArray, NDArray, Info)
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);.
public VectorStepResult(TObs Observations, NDArray Rewards, NDArray Terminations, NDArray Truncations, Info Infos)
Parameters
ObservationsTObsThe sub-envs' observations batched along the first axis (an array for array spaces); owned by the caller.
RewardsNDArrayA
(num_envs,)float64 array; owned by the caller.TerminationsNDArrayA
(num_envs,)bool array: which sub-envs reached a terminal state; owned by the caller.TruncationsNDArrayA
(num_envs,)bool array: which sub-envs were cut short (a time limit); owned by the caller.InfosInfoThe sub-envs' infos merged by key: each key holds a batch of the sub-envs' values (a
(num_envs, ...)array, or an object?[] for values that are not numbers or arrays), and its mask_keysays which sub-envs reported it.
Remarks
Equality is exact: arrays by shape, dtype and elements; the infos by Python's ==. Reference:
gymnasium/vector/vector_env.py (VectorEnv.step).
Properties
Infos
The sub-envs' infos merged by key: each key holds a batch of the sub-envs' values (a (num_envs, ...) array, or
an object?[] for values that are not numbers or arrays), and its mask _key says which
sub-envs reported it.
public Info Infos { get; init; }
Property Value
Observations
The sub-envs' observations batched along the first axis (an array for array spaces); owned by the caller.
public TObs Observations { get; init; }
Property Value
- TObs
Rewards
A (num_envs,) float64 array; owned by the caller.
public NDArray Rewards { get; init; }
Property Value
Terminations
A (num_envs,) bool array: which sub-envs reached a terminal state; owned by the caller.
public NDArray Terminations { get; init; }
Property Value
Truncations
A (num_envs,) bool array: which sub-envs were cut short (a time limit); owned by the caller.
public NDArray Truncations { get; init; }
Property Value
Methods
Dispose()
Releases every array of the result, the infos' included, so using var step = envs.Step(actions); frees them
at the end of the scope (the arrays a vector env returns belong to the caller, D19).
public void Dispose()
Remarks
Footgun: copies of this struct share the arrays; dispose once, after their last use, and copy what you keep.
Equals(VectorStepResult<TObs>)
Exact equality of every field (see the remarks), replacing the compiler's member-wise one, which would broadcast arrays.
public bool Equals(VectorStepResult<TObs> other)
Parameters
otherVectorStepResult<TObs>The other result.
Returns
GetHashCode()
A hash consistent with Equals(VectorStepResult<TObs>): shapes and counts only, as arrays have no value hash.
public override int GetHashCode()
Returns
- int
The hash.