Class OrderEnforcing<TObs, TAct>
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
TObsThe observation type, passed through.
TActThe 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
Reference: gymnasium/wrappers/common.py.
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
envEnv<TObs, TAct>The env to wrap.
optionsOrderEnforcingOptionsThe options.
Exceptions
- ArgumentNullException
Thrown when
optionsis null.
OrderEnforcing(Env<TObs, TAct>, bool)
Wraps env.
public OrderEnforcing(Env<TObs, TAct> env, bool disableRenderOrderEnforcing = false)
Parameters
envEnv<TObs, TAct>The env whose call order is enforced.
disableRenderOrderEnforcingboolAllow Render() before the first reset.
Exceptions
Properties
HasReset
Whether the env has been reset through this wrapper (has_reset).
public bool HasReset { get; }
Property Value
SavedKwargs
The recorded constructor arguments, {'disable_render_order_enforcing': False} (Python's _saved_kwargs).
[PyName("_saved_kwargs")]
public Info SavedKwargs { get; }
Property Value
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
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 callenv.render()before callingenv.reset(), if this is an intended action, setdisable_render_order_enforcing=Trueon 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
seedBigInteger?The seed, passed on.
optionsIReadOnlyDictionary<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
actionTActThe 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().