Table of Contents

Class DictInfoToList<TObs, TAct>

Namespace
Gym.Wrappers.Vector
Assembly
Gym.dll

Converts the vector env's dict of batched infos into a list of one info dict per sub-env, as Gymnasium's DictInfoToList does: each key's array is split by sub-env, the _key masks say which sub-envs have the key, and nested dicts convert likewise.

public class DictInfoToList<TObs, TAct> : VectorWrapper<TObs, TAct>, IVectorEnv, IDisposable

Type Parameters

TObs

The batched observation type, passed through.

TAct

The batched action type, passed through.

Inheritance
VectorEnv<TObs, TAct>
VectorWrapper<TObs, TAct, TObs, TAct>
VectorWrapper<TObs, TAct>
DictInfoToList<TObs, TAct>
Implements
Inherited Members
Extension Methods

Remarks

A vector env's results carry a dict of infos (VectorStepResult<TObs>), so the list comes from this class's own Step(TAct) and Reset(BigInteger?, IReadOnlyDictionary<string, object?>?), which hide the base ones: called on a DictInfoToList<TObs, TAct> they return Gymnasium's lists; called through IVectorEnv or VectorEnv<TObs, TAct> they return the dict unchanged. Put it outermost, as Gymnasium's wrappers that read infos expect a dict too. Each element is a copy (NumPy's scalar of the batch), so the list outlives the batch.

Reference: gymnasium/wrappers/vector/dict_info_to_list.py.

Constructors

DictInfoToList(VectorEnv<TObs, TAct>)

Wraps env.

public DictInfoToList(VectorEnv<TObs, TAct> env)

Parameters

env VectorEnv<TObs, TAct>

The vector env.

Exceptions

TypeError

Thrown when env is null.

Methods

ConvertInfoToList(IReadOnlyDictionary<string, object?>)

The dict of batched infos as one info per sub-env (convert_info_to_list): keys starting with are masks and are skipped, a key's mask (when present) keeps it only for the sub-envs it marks, and dicts convert recursively.

public IReadOnlyList<Info> ConvertInfoToList(IReadOnlyDictionary<string, object?> vectorInfos)

Parameters

vectorInfos IReadOnlyDictionary<string, object>

The env's infos.

Returns

IReadOnlyList<Info>

The list, one new info per sub-env.

Exceptions

AssertionError

Thrown when a value is neither a dict nor an array, or its length is not the number of sub-envs, with Gymnasium's messages.

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

Resets the env and converts its infos to a list (Gymnasium's reset).

public VectorListResetResult<TObs> Reset(BigInteger? seed = null, IReadOnlyDictionary<string, object?>? options = null)

Parameters

seed BigInteger?

The seed, passed on.

options IReadOnlyDictionary<string, object>

The options, passed on.

Returns

VectorListResetResult<TObs>

The first observations with one info per sub-env.

Exceptions

AssertionError

Thrown when an info value is neither a dict nor an array of one entry per sub-env.

Step(TAct)

Steps the env and converts its infos to a list (Gymnasium's step).

public VectorListStepResult<TObs> Step(TAct actions)

Parameters

actions TAct

The actions, passed on.

Returns

VectorListStepResult<TObs>

The transition with one info per sub-env.

Exceptions

AssertionError

Thrown when an info value is neither a dict nor an array of one entry per sub-env.