Table of Contents

Struct VectorStepResult<TObs>

Namespace
Gym.Vector
Assembly
Gym.dll

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

TObs

The batched observation type, an element of the vector env's batched observation space.

Implements
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

Observations TObs

The sub-envs' observations batched along the first axis (an array for array spaces); owned by the caller.

Rewards NDArray

A (num_envs,) float64 array; owned by the caller.

Terminations NDArray

A (num_envs,) bool array: which sub-envs reached a terminal state; owned by the caller.

Truncations NDArray

A (num_envs,) bool array: which sub-envs were cut short (a time limit); owned by the caller.

Infos Info

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.

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

Info

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

NDArray

Terminations

A (num_envs,) bool array: which sub-envs reached a terminal state; owned by the caller.

public NDArray Terminations { get; init; }

Property Value

NDArray

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

NDArray

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

other VectorStepResult<TObs>

The other result.

Returns

bool

true when the results are equal.

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.