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
这是什么?Gymnasium 是一个开源的 Python 库,提供了用于单智能体强化学习环境的标准 API,并附带一套常用的参考环境。它是 OpenAI Gym 的维护分支,在 OpenAI 将其移交之后继续开发。
这是一个框架,还是只是一批现成的环境?两者都是:它既提供了标准 API(基于 reset/step 方法的 Python 环境类),任何强化学习算法都可以对接;同时也提供了一系列开箱即用的参考环境,例如 Classic Control、Box2D、MuJoCo 和 Atari。
我该如何安装并开始使用某个环境?使用 'pip install gymnasium' 安装基础库,然后创建环境实例并与之交互,例如 'CartPole-v1' 环境。
像 Atari 或 MuJoCo 这类特定环境系列是否需要额外的软件包?需要。基础安装不包含所有环境系列的依赖项,你需要按系列安装扩展包,例如 'pip install "gymnasium[atari]"',或者使用 'pip install "gymnasium[all]"' 安装全部内容。
为 Gym 环境编写的旧代码能直接在这里运行吗?不一定。环境有严格的版本编号,后缀如 '-v0',而第三方环境可能针对较旧的 API 版本编写,因此你可能需要在 gymnasium.make 中使用 'applyenvcompatibility' 来做兼容处理。
开箱即用的环境系列有哪些?Classic Control、Box2D、Toy Text、MuJoCo 和 Atari,以及许多兼容的第三方环境。
为什么环境版本管理很重要?Gymnasium 对环境实行严格的版本管理(例如 '-v0'、'-v1'),因此任何影响学习结果的改动都会提升版本号,从而保证结果可复现,避免行为悄然发生变化。
是否有基于 Gymnasium 构建的相关库?CleanRL 提供基于 Gymnasium API 的强化学习算法参考实现,PettingZoo 则将同样的 API 设计扩展到多智能体环境。
为什么要创建这个项目,而不直接使用 OpenAI Gym?几年前 OpenAI 将 Gym 的维护工作移交给了外部团队,Gymnasium 就是该团队维护的分支,今后所有的开发和维护工作都在这里进行。
Size
444.5 MB
Stars
12.7K
Age
4y
Commits · 90 Days