Class ClassicControlUtils
- Namespace
- Gym.Environments.Envs.Classic
- Assembly
- Gym.Environments.dll
The reset-option parsing every classic-control env shares, so Reset(seed, options) accepts and rejects
exactly what Gymnasium's reset does, with the same messages.
public static class ClassicControlUtils
- Inheritance
-
ClassicControlUtils
- Inherited Members
Remarks
Reference: gymnasium/envs/classic_control/utils.py.
Methods
MaybeParseResetBounds(IReadOnlyDictionary<string, object?>?, double, double)
The bounds a reset draws its initial state from: options["low"] and options["high"] where given,
the defaults otherwise.
public static (double Low, double High) MaybeParseResetBounds(IReadOnlyDictionary<string, object?>? options, double defaultLow, double defaultHigh)
Parameters
optionsIReadOnlyDictionary<string, object>The reset options (Python's
optionsdict), or null for the defaults. Other keys are ignored.defaultLowdoubleThe lower bound when
"low"is absent.defaultHighdoubleThe upper bound when
"high"is absent.
Returns
- (double From, double To)
The bounds, both converted by VerifyNumberAndCast(object?).
Remarks
Equal bounds are accepted, and NaN passes the comparison (nan > x is false), exactly as in Python; a NaN or
infinite bound then fails in the generator's uniform instead (high - low range exceeds valid bounds).
Reference: gymnasium/envs/classic_control/utils.py.
Exceptions
- ValueError
Thrown for a bound
float()rejects (a present key with a null value included, which is Python'sNone), and when the lower bound exceeds the upper one:Lower bound (0.1) must be lower than higher bound (-0.1).- OverflowError
Thrown for an integer bound beyond the float range.
VerifyNumberAndCast(object?)
Converts a reset option with Python's float(x), turning its ValueError and TypeError into
one ValueError that names the option.
public static double VerifyNumberAndCast(object? x)
Parameters
xobjectThe option's value: a number, a numeric string (
"-0.5","1_0"), a 0-d array...
Returns
- double
The value as a float.
Remarks
Reference: gymnasium/envs/classic_control/utils.py.
Exceptions
- ValueError
Thrown when Python's
float()rejects the value:An option (abc) could not be converted to a float.({x}is Python'sstr(x), see Str(object?)).- OverflowError
Thrown, as Python's
OverflowError, for an integer beyond the float range: Gymnasium catches onlyValueErrorandTypeError, so this one propagates unchanged.