Table of Contents

Class ObstructView<TObs, TAct>

Namespace
Gym.Wrappers
Assembly
Gym.dll

Covers random square patches of the rendered frame with white noise, as Gymnasium's ObstructView does: about obstructed_pixels_ratio of the pixels in patches obstruction_width wide.

public class ObstructView<TObs, TAct> : Wrapper<TObs, TAct>, IDynamicAttributes, IWrapper, IEnv, IDisposable, IRecordConstructorArgs

Type Parameters

TObs

The observation type, passed through.

TAct

The action type, passed through.

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

Remarks

Every render draws the patch centres and then the noise from the env's generator, so rendering advances the env's stream. Patches near the edge are cut by it and patches overlap, so the covered share is at most the ratio. The frame must be an array (rgb_array); the result is a new array, uint8 for RGB noise and uint64 for grayscale noise, as in Gymnasium.

Reference: gymnasium/wrappers/rendering.py.

Constructors

ObstructView(Env<TObs, TAct>, ObstructViewOptions)

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

public ObstructView(Env<TObs, TAct> env, ObstructViewOptions options)

Parameters

env Env<TObs, TAct>

The env to wrap.

options ObstructViewOptions

The options.

Exceptions

ArgumentNullException

Thrown when options is null.

TypeError

Thrown when a required argument is unset, with Python's missing-argument message.

ObstructView(Env<TObs, TAct>, double, long, bool)

Wraps env.

public ObstructView(Env<TObs, TAct> env, double obstructedPixelsRatio, long obstructionWidth, bool isNoiseGrayscale = false)

Parameters

env Env<TObs, TAct>

The env; it must render arrays.

obstructedPixelsRatio double

The share of pixels to cover, in [0, 1).

obstructionWidth long

The side of each square patch, at least 1.

isNoiseGrayscale bool

Whether the noise is gray rather than colored.

Exceptions

ValueError

Thrown for a ratio outside [0, 1) or a width below 1, with Gymnasium's messages.

TypeError

Thrown when env is null.

Properties

IsNoiseGrayscale

Whether the noise is gray (is_noise_grayscale).

public bool IsNoiseGrayscale { get; set; }

Property Value

bool

ObstructionCentersRatio

The patch centres per pixel (obstruction_centers_ratio): the ratio over the patch's area.

public double ObstructionCentersRatio { get; set; }

Property Value

double

ObstructionWidth

The side of each patch (obstruction_width).

public long ObstructionWidth { get; set; }

Property Value

long

SavedKwargs

The recorded constructor arguments (Python's _saved_kwargs).

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

Property Value

Info

Methods

Render()

The env's frame with noise in the patches.

public override RenderResult Render()

Returns

RenderResult

A new frame (RenderResult.Rgb) the caller owns.

Exceptions

AttributeError

Thrown when the env's render is not an array, as Python's render_out.shape raises.