Table of Contents

Class AddRenderObservation<TObs, TAct>

Namespace
Gym.Wrappers
Assembly
Gym.dll

Puts the rendered frame into every observation, as Gymnasium's AddRenderObservation does: with render_only the frame replaces the observation, otherwise it joins it in a dict (beside a Dict's keys, or as {obs_key: obs, render_key: frame}).

public class AddRenderObservation<TObs, TAct> : TransformObservation<object?, TObs, TAct>, IDynamicAttributes, IWrapper, IEnv, IDisposable, IRecordConstructorArgs

Type Parameters

TObs

The env's observation type.

TAct

The action type, passed through.

Inheritance
Env<object, TAct>
Wrapper<object, TAct, TObs, TAct>
AddRenderObservation<TObs, TAct>
Implements
Inherited Members
Extension Methods

Remarks

The constructor resets the env and renders once to learn the frame's shape, as Gymnasium's does: the reset draws from the env's generator (seeding it from entropy if it was never seeded), so seed the next reset to reproduce a run. Each observation renders again; the env's render mode must give arrays (rgb_array, depth_array). The observation type depends on render_only at run time (an array, or a dict), so observations are objects.

Reference: gymnasium/wrappers/transform_observation.py.

Constructors

AddRenderObservation(Env<TObs, TAct>, AddRenderObservationOptions)

Builds the instance from its options record: the properties set, the constructor's defaults for the rest.

public AddRenderObservation(Env<TObs, TAct> env, AddRenderObservationOptions options)

Parameters

env Env<TObs, TAct>

The env to wrap.

options AddRenderObservationOptions

The options.

Exceptions

ArgumentNullException

Thrown when options is null.

AddRenderObservation(Env<TObs, TAct>, bool, string, string)

Wraps env.

public AddRenderObservation(Env<TObs, TAct> env, bool renderOnly = true, string renderKey = "pixels", string obsKey = "state")

Parameters

env Env<TObs, TAct>

The env; its render mode must be set and not human.

renderOnly bool

Whether the frame replaces the observation (the default) instead of joining it in a dict.

renderKey string

The frame's key in the dict.

obsKey string

The observation's key when the env's space is no Dict.

Exceptions

ValueError

Thrown when the render mode is unset or human, or renderKey already is a key of the env's Dict space, with Gymnasium's messages.

TypeError

Thrown when rendering gives no array (Gymnasium's message), or env is null.

Properties

ObsKey

The observation's key beside the frame (obs_key).

public string ObsKey { get; }

Property Value

string

RenderKey

The frame's key (render_key).

public string RenderKey { get; }

Property Value

string

RenderOnly

Whether the frame replaces the observation (render_only).

public bool RenderOnly { get; }

Property Value

bool