Table of Contents

Class GymOptionsAttribute

Namespace
Gym.Utils
Assembly
Gym.dll

Asks Gym.NET's source generator for an options record (DR-34): on a partial env or wrapper class it writes a <Class>Options record with one property per parameter of the public constructor make binds to (a wrapper's env excepted), its ToKwargs(), and a constructor of the class that takes the record. Gymnasium.Make("CartPole-v1", new CartPoleEnvOptions { RenderMode = "rgb_array" }) is then checked by the compiler where a dictionary of kwargs is not.

[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public sealed class GymOptionsAttribute : Attribute
Inheritance
GymOptionsAttribute
Inherited Members
Extension Methods

Remarks

The record follows the constructor on every build, so it cannot drift from it. Only the properties that are set become kwargs: the registered spec's values and the constructor's defaults stand for the others. A class that is not partial fails to compile (CS0260), as the generator adds the constructor to it.