Table of Contents

Class OrderEnforcing<TObs, TAct>

Namespace
Gym.Wrappers
Assembly
Gym.dll

Raises ResetNeeded when step or render is called before the first reset, a mistake that would otherwise fail somewhere inside the env with a less helpful error. make adds it unless the spec disables order_enforce.

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

Remarks

Constructors

OrderEnforcing(Env<TObs, TAct>, OrderEnforcingOptions)

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

public OrderEnforcing(Env<TObs, TAct> env, OrderEnforcingOptions options)

Parameters

env Env<TObs, TAct>

The env to wrap.

options OrderEnforcingOptions

The options.

Exceptions

ArgumentNullException

Thrown when options is null.

OrderEnforcing(Env<TObs, TAct>, bool)

Wraps env.

public OrderEnforcing(Env<TObs, TAct> env, bool disableRenderOrderEnforcing = false)

Parameters

env Env<TObs, TAct>

The env whose call order is enforced.

disableRenderOrderEnforcing bool

Allow Render() before the first reset.

Exceptions

TypeError

Thrown when env is null.

Properties

HasReset

Whether the env has been reset through this wrapper (has_reset).

public bool HasReset { get; }

Property Value

bool

SavedKwargs

The recorded constructor arguments, {'disable_render_order_enforcing': False} (Python's _saved_kwargs).

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

Property Value

Info

Spec

The env's spec with OrderEnforce set (a deep copy, cached), or null when the env has none. No WrapperSpec is added: order enforcing is part of the spec itself.

public override EnvSpec? Spec { get; set; }

Property Value

EnvSpec

Exceptions

AttributeError

Thrown when assigned, as for every wrapper.

Methods

Render()

Renders the env, once it has been reset or when render order enforcing is disabled.

public override RenderResult Render()

Returns

RenderResult

The env's rendering.

Exceptions

ResetNeeded

Thrown before the first reset: Cannot call env.render() before calling env.reset(), if this is an intended action, set disable_render_order_enforcing=True on the OrderEnforcer wrapper.

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

Records the reset, then resets the env.

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

ResetResult<TObs>

The env's first observation and info.

Remarks

The reset counts even when the env's reset then fails, as in Python, where the flag is set first.

Exceptions

Error

Thrown for a negative seed.

Step(TAct)

Steps the env, once it has been reset.

public override StepResult<TObs> Step(TAct action)

Parameters

action TAct

The action, passed on.

Returns

StepResult<TObs>

The env's transition.

Exceptions

ResetNeeded

Thrown before the first reset: Cannot call env.step() before calling env.reset().