Table of Contents

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

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

options IReadOnlyDictionary<string, object>

The reset options (Python's options dict), or null for the defaults. Other keys are ignored.

defaultLow double

The lower bound when "low" is absent.

defaultHigh double

The 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's None), 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

x object

The option's value: a number, a numeric string ("-0.5", "1_0"), a 0-d array...

Returns

double

The value as a float.

Remarks

Exceptions

ValueError

Thrown when Python's float() rejects the value: An option (abc) could not be converted to a float. ({x} is Python's str(x), see Str(object?)).

OverflowError

Thrown, as Python's OverflowError, for an integer beyond the float range: Gymnasium catches only ValueError and TypeError, so this one propagates unchanged.