Gymnasium README

The project's README from github.com/Farama-Foundation/Gymnasium. As one markdown file: README.md.

Python PyPI arXiv pre-commit License Code style: black

Gymnasium is an 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. This is a fork of OpenAI's Gym library by its maintainers (OpenAI handed over maintenance a few years ago to an outside team), and is where future maintenance will occur going forward.

The documentation website is at gymnasium.farama.org, and we have a public discord server (which we also use to coordinate development work) that you can join here: https://discord.gg/bnJ6kubTg6

Environments

Gymnasium includes the following families of environments along with a wide variety of third-party environments

Installation

To install the base Gymnasium library, use pip install gymnasium

This does not include dependencies for all families of environments (there's a massive number, and some can be problematic to install on certain systems). You can install these dependencies for one family like pip install "gymnasium[atari]" or use pip install "gymnasium[all]" to install all dependencies.

API

The Gymnasium API models environments as simple Python env classes. Creating environment instances and interacting with them is very simple- here's an example using the "CartPole-v1" environment:

import gymnasium as gym
env = gym.make("CartPole-v1")

observation, info = env.reset(seed=42)
for _ in range(1000):
    action = env.action_space.sample()
    observation, reward, terminated, truncated, info = env.step(action)

    if terminated or truncated:
        observation, info = env.reset()
env.close()

Please note that this is an incomplete list, and just includes libraries that the maintainers most commonly point newcomers to when asked for recommendations.

Environment Versioning

Gymnasium keeps strict versioning for reproducibility reasons. All environments end in a suffix like "-v0". When changes are made to environments that might impact learning results, the number is increased by one to prevent potential confusion. These were inherited from Gym.

Contributing

We welcome contributions from the community! Please see our CONTRIBUTING.md for details on how to get started.

Support Gymnasium's Development

If you are financially able to do so and would like to support the development of Gymnasium, please join others in the community in donating to us.

Citation

You can cite Gymnasium using our related paper (https://arxiv.org/abs/2407.17032) as:

@article{towers2024gymnasium,
  title={Gymnasium: A Standard Interface for Reinforcement Learning Environments},
  author={Towers, Mark and Kwiatkowski, Ariel and Terry, Jordan and Balis, John U and De Cola, Gianluca and Deleu, Tristan and Goul{\~a}o, Manuel and Kallinteris, Andreas and Krimmel, Markus and KG, Arjun and others},
  journal={arXiv preprint arXiv:2407.17032},
  year={2024}
}

Gymnasium (Farama-Foundation/Gymnasium)

Searching Database…

12.7K ·GitHub
What is this?Gymnasium is an open source Python library that provides a standard API for single-agent reinforcement learning environments, along with a set of popular reference environments. It is the maintained fork of OpenAI's Gym, continuing development after OpenAI handed it over.
Is this a framework or just a bunch of pre-built environments?It is both: a standard API (Python env classes with reset/step methods) that any RL algorithm can target, plus a collection of ready-to-use reference environments like Classic Control, Box2D, MuJoCo, and Atari.
How do I install it and start using an environment?Install the base library with 'pip install gymnasium', then create and interact with an environment instance, for example the 'CartPole-v1' environment.
Do I need extra packages for specific environment families like Atari or MuJoCo?Yes, the base install doesn't include every environment family's dependencies; you install extras per family, e.g. 'pip install "gymnasium[atari]"', or 'pip install "gymnasium[all]"' for everything.
Will old code written for Gym environments just work here?Not necessarily — environments are strictly versioned with suffixes like '-v0', and third-party environments may target an older API version, so you may need 'applyenvcompatibility' in gymnasium.make to bridge compatibility.
What environment families does it include out of the box?Classic Control, Box2D, Toy Text, MuJoCo, and Atari, plus many compatible third-party environments.
Why does environment versioning matter here?Gymnasium strictly versions environments (e.g. '-v0', '-v1') so that any change affecting learning results bumps the version, keeping results reproducible and avoiding silent behavior changes.
Are there related libraries built on top of Gymnasium?CleanRL offers reference RL algorithm implementations using the Gymnasium API, and PettingZoo extends the same API design to multi-agent environments.
Why was this created instead of just using OpenAI Gym?OpenAI handed over Gym's maintenance to an outside team a few years ago, and Gymnasium is that team's fork where all future development and maintenance now happens.
Size
444.5 MB
Stars
12.7K
Age
4y
Commits · 90 Days