Table of Contents

Class HumanRenderingVector<TObs, TAct>

Namespace
Gym.Wrappers.Vector
Assembly
Gym.dll

Shows a vector env's sub-envs in one window, tiled, as Gymnasium's vector HumanRendering does: every reset and step renders the sub-envs, scales each frame to fit the grid (OpenCV's bilinear cv2.resize), and shows the mosaic at metadata["render_fps"].

[PyName("HumanRendering")]
public class HumanRenderingVector<TObs, TAct> : VectorWrapper<TObs, TAct>, IVectorEnv, IDisposable, IRecordConstructorArgs

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>
HumanRenderingVector<TObs, TAct>
Implements
Inherited Members
Extension Methods

Remarks

The window is a viewer from the wrapper's own factory, else Gymnasium.HumanViewerFactory (DR-20, DR-89), opened at the screen size (by default a sub-env's frame size), with the grid's rows and columns chosen once, as Gymnasium chooses them. Frames are paced by Clock. LastMosaic keeps the last mosaic shown, (width, height, 3) as pygame's surfaces are laid out.

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

Constructors

HumanRenderingVector(VectorEnv<TObs, TAct>, (int Width, int Height)?)

Wraps env.

public HumanRenderingVector(VectorEnv<TObs, TAct> env, (int Width, int Height)? screenSize = null)

Parameters

env VectorEnv<TObs, TAct>

The vector env; its render mode must be one of AcceptedRenderModes, and its metadata must have render_fps.

screenSize (int Width, int Height)?

The window's (width, height); null for a sub-env's frame size.

Exceptions

ValueError

Thrown for another render mode, or metadata without render_fps, with Gymnasium's messages.

TypeError

Thrown when env is null.

Fields

AcceptedRenderModes

The render modes the wrapper can show (ACCEPTED_RENDER_MODES).

public static readonly IReadOnlyList<string> AcceptedRenderModes

Field Value

IReadOnlyList<string>

Properties

LastMosaic

The last mosaic shown, (width, height, 3) uint8 (pygame's surface layout); owned by the wrapper.

public NDArray? LastMosaic { get; }

Property Value

NDArray

NumCols

The grid's columns (num_cols), or null before the first frame.

public int? NumCols { get; }

Property Value

int?

NumRows

The grid's rows (num_rows), or null before the first frame.

public int? NumRows { get; }

Property Value

int?

RenderMode

Always human.

public override string? RenderMode { get; protected set; }

Property Value

string

Exceptions

AttributeError

Thrown when assigned, as for every wrapper.

SavedKwargs

The recorded constructor arguments (Python's _saved_kwargs).

[PyName("_saved_kwargs")]
public Info SavedKwargs { get; }

Property Value

Info

ScaledSubenvSize

The size each sub-env's frame is scaled to, (width, height) (scaled_subenv_size), or null before the first frame.

public (int Width, int Height)? ScaledSubenvSize { get; }

Property Value

(int Width, int Height)?

ScreenSize

The window's (width, height) (screen_size), a sub-env frame's size once the first frame came when none was given.

public (int Width, int Height)? ScreenSize { get; }

Property Value

(int Width, int Height)?

ViewerFactory

Gym.NET's viewer factory for this wrapper's window (DR-20, DR-89): set it before the first frame (new HumanRenderingVector<TObs, TAct>(env) { ViewerFactory = factory }); null (the default) uses Gymnasium.HumanViewerFactory, read when the window opens. A property, not a constructor argument, so the constructor and the arguments it records stay Gymnasium's.

public EnvViewerFactory? ViewerFactory { get; set; }

Property Value

EnvViewerFactory

Remarks

Set after the window opened, it takes effect only if the window is closed and opens again.

Methods

Close()

Closes the window, then the env.

public override void Close()

Dispose(bool)

Releases the last mosaic, then disposes as every vector wrapper does.

protected override void Dispose(bool disposing)

Parameters

disposing bool

true from Dispose().

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

Resets the env with one seed per sub-env, then shows its sub-envs' frames.

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

Parameters

seeds IReadOnlyList<BigInteger?>

The seeds, passed on.

options IReadOnlyDictionary<string, object>

The options, passed on.

Returns

VectorResetResult<TObs>

The env's reset.

Exceptions

DependencyNotInstalled

Thrown at the first frame when no viewer factory is set.

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

Resets the env, then shows its sub-envs' frames.

public override VectorResetResult<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

VectorResetResult<TObs>

The env's reset.

Exceptions

DependencyNotInstalled

Thrown at the first frame when no viewer factory is set.

Step(TAct)

Steps the env, then shows its sub-envs' frames.

public override VectorStepResult<TObs> Step(TAct actions)

Parameters

actions TAct

The actions, passed on.

Returns

VectorStepResult<TObs>

The env's transition.

Exceptions

DependencyNotInstalled

Thrown at the first frame when no viewer factory is set.