Table of Contents

Class GymEnvironments

Namespace
Gym.Environments
Assembly
Gym.Environments.dll

Registers Gym.NET's built-in env ids with the registry, as importing gymnasium registers Gymnasium's (gymnasium/envs/init.py): the same ids, step limits and reward thresholds, with the env classes as entry points (DR-12). After it, Gymnasium.Make("CartPole-v1") works.

public static class GymEnvironments
Inheritance
GymEnvironments
Inherited Members

Remarks

Nothing needs to call it in a C# app: the package compiles a module initializer into the app that calls RegisterUnlessDisabled() before Main (DR-17), and this assembly's own module initializer does the same when it is loaded first. F# and Visual Basic apps call Register() at start-up.

Setting the environment variable DisableRegistrationVariable (to anything but 0 or false) turns both initializers off (DR-14), for an app that registers its own ids under the same names; Register() still registers when called.

Ids register in Gymnasium's order as their phases port them: classic_control's (CartPole-v0/v1, MountainCar-v0, MountainCarContinuous-v0, Pendulum-v1, Acrobot-v1), box2d's (LunarLander-v3, LunarLanderContinuous-v3, BipedalWalker-v3, BipedalWalkerHardcore-v3, CarRacing-v3), toy_text's (Blackjack-v1, FrozenLake-v1, FrozenLake8x8-v1, CliffWalking-v1, CliffWalkingSlippery-v1, Taxi-v4) and mujoco's 22 (Reacher, Pusher, InvertedPendulum, InvertedDoublePendulum, HalfCheetah, Hopper, Swimmer, Walker2d, Ant, Humanoid and HumanoidStandup, each v4 and v5; Pusher-v4 refuses at construction, as Gymnasium's does on MuJoCo 3 and later). CartPole's two register CartPoleVectorEnv as their vectorized entry point.

Reference: gymnasium/envs/__init__.py.

Fields

DisableRegistrationVariable

The environment variable that disarms the automatic registration (DR-14): GYMNET_DISABLE_ENV_REGISTRATION.

public const string DisableRegistrationVariable = "GYMNET_DISABLE_ENV_REGISTRATION"

Field Value

string

Properties

IsAutomaticRegistrationDisabled

Whether DisableRegistrationVariable disarms the automatic registration: it is set to anything but empty, 0 or false (case-insensitive).

public static bool IsAutomaticRegistrationDisabled { get; }

Property Value

bool

Methods

Register()

Registers every built-in id, once per process: later calls do nothing, so an id an app removed from the registry stays removed. Registering an id the app already registered replaces it with Gymnasium's Overriding environment ... already in registry. warning.

public static void Register()

Exceptions

RegistrationError

Thrown when the app registered a name both ways (versioned and not) first.

RegisterUnlessDisabled()

What the module initializers call: Register(), unless DisableRegistrationVariable disarms it. The app-side initializer the package compiles into a C# app is this one call (DR-17).

public static void RegisterUnlessDisabled()

Exceptions

RegistrationError

Thrown when the app registered a name both ways first.