Class ObstructView<TObs, TAct>
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
TObsThe observation type, passed through.
TActThe 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
envEnv<TObs, TAct>The env to wrap.
optionsObstructViewOptionsThe options.
Exceptions
- ArgumentNullException
Thrown when
optionsis 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
envEnv<TObs, TAct>The env; it must render arrays.
obstructedPixelsRatiodoubleThe share of pixels to cover, in [0, 1).
obstructionWidthlongThe side of each square patch, at least 1.
isNoiseGrayscaleboolWhether 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
envis null.
Properties
IsNoiseGrayscale
Whether the noise is gray (is_noise_grayscale).
public bool IsNoiseGrayscale { get; set; }
Property Value
ObstructionCentersRatio
The patch centres per pixel (obstruction_centers_ratio): the ratio over the patch's area.
public double ObstructionCentersRatio { get; set; }
Property Value
ObstructionWidth
The side of each patch (obstruction_width).
public long ObstructionWidth { get; set; }
Property Value
SavedKwargs
The recorded constructor arguments (Python's _saved_kwargs).
[PyName("_saved_kwargs")]
public Info SavedKwargs { get; }
Property Value
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.shaperaises.