Registry#

Gymnasium allows users to automatically load environments, pre-wrapped with several important wrappers. Environments can also be created through python imports.

Make#

gymnasium.make(id: str, **kwargs) Env#
gymnasium.make(id: EnvSpec, **kwargs) Env
gymnasium.make(id: Literal['CartPole-v0', 'CartPole-v1'], **kwargs) Env[np.ndarray, np.ndarray | int]
gymnasium.make(id: Literal['MountainCar-v0'], **kwargs) Env[np.ndarray, np.ndarray | int]
gymnasium.make(id: Literal['MountainCarContinuous-v0'], **kwargs) Env[np.ndarray, np.ndarray | Sequence[SupportsFloat]]
gymnasium.make(id: Literal['Pendulum-v1'], **kwargs) Env[np.ndarray, np.ndarray | Sequence[SupportsFloat]]
gymnasium.make(id: Literal['Acrobot-v1'], **kwargs) Env[np.ndarray, np.ndarray | int]
gymnasium.make(id: Literal['LunarLander-v2', 'LunarLanderContinuous-v2'], **kwargs) Env[np.ndarray, np.ndarray | int]
gymnasium.make(id: Literal['BipedalWalker-v3', 'BipedalWalkerHardcore-v3'], **kwargs) Env[np.ndarray, np.ndarray | Sequence[SupportsFloat]]
gymnasium.make(id: Literal['CarRacing-v2'], **kwargs) Env[np.ndarray, np.ndarray | Sequence[SupportsFloat]]
gymnasium.make(id: Literal['Blackjack-v1'], **kwargs) Env[np.ndarray, np.ndarray | int]
gymnasium.make(id: Literal['FrozenLake-v1', 'FrozenLake8x8-v1'], **kwargs) Env[np.ndarray, np.ndarray | int]
gymnasium.make(id: Literal['CliffWalking-v0'], **kwargs) Env[np.ndarray, np.ndarray | int]
gymnasium.make(id: Literal['Taxi-v3'], **kwargs) Env[np.ndarray, np.ndarray | int]
gymnasium.make(id: Literal['Reacher-v2', 'Reacher-v4', 'Pusher-v2', 'Pusher-v4', 'InvertedPendulum-v2', 'InvertedPendulum-v4', 'InvertedDoublePendulum-v2', 'InvertedDoublePendulum-v4', 'HalfCheetah-v2', 'HalfCheetah-v3', 'HalfCheetah-v4', 'Hopper-v2', 'Hopper-v3', 'Hopper-v4', 'Swimmer-v2', 'Swimmer-v3', 'Swimmer-v4', 'Walker2d-v2', 'Walker2d-v3', 'Walker2d-v4', 'Ant-v2', 'Ant-v3', 'Ant-v4', 'HumanoidStandup-v2', 'HumanoidStandup-v4', 'Humanoid-v2', 'Humanoid-v3', 'Humanoid-v4'], **kwargs) Env[ndarray, ndarray]

Create an environment according to the given ID.

To find all available environments use gymnasium.envs.registry.keys() for all valid ids.

Parameters:
  • id – Name of the environment. Optionally, a module to import can be included, eg. ‘module:Env-v0’

  • max_episode_steps – Maximum length of an episode (TimeLimit wrapper).

  • autoreset – Whether to automatically reset the environment after each episode (AutoResetWrapper).

  • apply_api_compatibility – Whether to wrap the environment with the StepAPICompatibility wrapper that converts the environment step from a done bool to return termination and truncation bools. By default, the argument is None to which the environment specification apply_api_compatibility is used which defaults to False. Otherwise, the value of apply_api_compatibility is used. If True, the wrapper is applied otherwise, the wrapper is not applied.

  • disable_env_checker – If to run the env checker, None will default to the environment specification disable_env_checker (which is by default False, running the environment checker), otherwise will run according to this parameter (True = not run, False = run)

  • kwargs – Additional arguments to pass to the environment constructor.

Returns:

An instance of the environment.

Raises:

Error – If the id doesn’t exist then an error is raised

Register#

gymnasium.register(id: str, entry_point: Callable | str, reward_threshold: float | None = None, nondeterministic: bool = False, max_episode_steps: int | None = None, order_enforce: bool = True, autoreset: bool = False, disable_env_checker: bool = False, apply_api_compatibility: bool = False, **kwargs)#

Register an environment with gymnasium.

The id parameter corresponds to the name of the environment, with the syntax as follows: (namespace)/(env_name)-v(version) where namespace is optional.

It takes arbitrary keyword arguments, which are passed to the EnvSpec constructor.

Parameters:
  • id – The environment id

  • entry_point – The entry point for creating the environment

  • reward_threshold – The reward threshold considered to have learnt an environment

  • nondeterministic – If the environment is nondeterministic (even with knowledge of the initial seed and all actions)

  • max_episode_steps – The maximum number of episodes steps before truncation. Used by the Time Limit wrapper.

  • order_enforce – If to enable the order enforcer wrapper to ensure users run functions in the correct order

  • autoreset – If to add the autoreset wrapper such that reset does not need to be called.

  • disable_env_checker – If to disable the environment checker for the environment. Recommended to False.

  • apply_api_compatibility – If to apply the StepAPICompatibility wrapper.

  • **kwargs – arbitrary keyword arguments which are passed to the environment constructor

All registered environments#

To find all the registered Gymnasium environments, use the gymnasium.pprint_registry(). This will not include environments registered only in OpenAI Gym however can be loaded by gymnasium.make.

Spec#

gymnasium.spec(env_id: str) EnvSpec#

Retrieve the spec for the given environment from the global registry.

Pretty print registry#

gymnasium.pprint_registry(_registry: dict = registry, num_cols: int = 3, exclude_namespaces: list[str] | None = None, disable_print: bool = False) str | None#

Pretty print the environments in the registry.

Parameters:
  • _registry – Environment registry to be printed.

  • num_cols – Number of columns to arrange environments in, for display.

  • exclude_namespaces – Exclude any namespaces from being printed.

  • disable_print – Whether to return a string of all the namespaces and environment IDs instead of printing it to console.