OpenAI Gym#

Installation#

pip install shimmy[gym]

Usage#

import gymnasium as gym

env = gym.make("GymV22CompatibilityV0", env_name="...")

Class Description#

class shimmy.openai_gym_compatibility.GymV26CompatibilityV0(env_id: str | None = None, make_kwargs: dict[str, Any] | None = None, env: gym.Env | None = None)#

This compatibility layer converts a Gym v26 environment to a Gymnasium environment.

Gym is the original open source Python library for developing and comparing reinforcement learning algorithms by providing a standard API to communicate between learning algorithms and environments, as well as a standard set of environments compliant with that API. Since its release, Gym’s API has become the field standard for doing this. In 2022, the team that has been maintaining Gym has moved all future development to Gymnasium.

observation_space: spaces.Space[ObsType]#
action_space: spaces.Space[ActType]#
reset(seed: int | None = None, options: dict | None = None) tuple[ObsType, dict]#

Resets the environment.

Parameters:
  • seed – the seed to reset the environment with

  • options – the options to reset the environment with

Returns:

(observation, info)

step(action: ActType) tuple[ObsType, float, bool, bool, dict]#

Steps through the environment.

Parameters:

action – action to step through the environment with

Returns:

(observation, reward, terminated, truncated, info)

render()#

Renders the environment.

Returns:

The rendering of the environment, depending on the render mode

close()#

Closes the environment.

shimmy.openai_gym_compatibility._strip_default_wrappers(env: gym.Env) gym.Env#

Strips builtin wrappers from the environment.

Parameters:

env – the environment to strip builtin wrappers from

Returns:

The environment without builtin wrappers

shimmy.openai_gym_compatibility._convert_space(space: gym.Space) gymnasium.Space#

Converts a gym space to a gymnasium space.

Parameters:

space – the space to convert

Returns:

The converted space