2022-09-13 20:27:34 +01:00
---
hide-toc: true
firstpage:
lastpage:
---
2023-06-12 11:20:44 +01:00
```{project-logo} _static/img/gymnasium-text.png
:alt: Gymnasium Logo
```
2022-09-13 20:27:34 +01:00
2023-06-12 11:20:44 +01:00
```{project-heading}
An API standard for reinforcement learning with a diverse collection of reference environments
```
2023-05-03 03:54:15 -04:00
2023-05-01 23:45:28 +02:00
```{figure} _static/videos/box2d/lunar_lander.gif
:alt: Lunar Lander
:width: 500
```
2022-09-13 20:27:34 +01:00
2023-11-07 13:27:25 +00:00
**Gymnasium is a maintained fork of OpenAI’ s Gym library.** The Gymnasium interface is simple, pythonic, and capable of representing general RL problems, and has a [compatibility wrapper ](introduction/gym_compatibility ) for old Gym environments:
2022-09-13 20:27:34 +01:00
2023-04-02 14:07:31 +02:00
```{code-block} python
2023-05-02 18:40:29 -04:00
import gymnasium as gym
2023-11-07 13:27:25 +00:00
# Initialise the environment
2023-05-02 18:40:29 -04:00
env = gym.make("LunarLander-v2", render_mode="human")
2023-11-07 13:27:25 +00:00
# Reset the environment to generate the first observation
2023-05-02 18:40:29 -04:00
observation, info = env.reset(seed=42)
for _ in range(1000):
2023-11-07 13:27:25 +00:00
# this is where you would insert your policy
action = env.action_space.sample()
# step (transition) through the environment with the action
# receiving the next observation, reward and if the episode has terminated or truncated
observation, reward, terminated, truncated, info = env.step(action)
2023-04-02 14:07:31 +02:00
2023-11-07 13:27:25 +00:00
# If the episode has ended then we can reset to start a new episode
if terminated or truncated:
observation, info = env.reset()
2023-04-02 14:07:31 +02:00
2022-09-13 20:27:34 +01:00
env.close()
2022-10-03 19:01:14 +01:00
```
2022-09-13 20:27:34 +01:00
```{toctree}
:hidden:
:caption: Introduction
2023-11-07 13:27:25 +00:00
introduction/basic_usage
introduction/gym_compatibility
introduction/migration-guide
2022-09-13 20:27:34 +01:00
```
```{toctree}
:hidden:
:caption: API
2022-10-12 15:58:01 +01:00
api/env
api/registry
2022-09-13 20:27:34 +01:00
api/spaces
api/wrappers
api/vector
api/utils
2023-11-07 13:27:25 +00:00
api/functional
2022-09-13 20:27:34 +01:00
```
```{toctree}
:hidden:
:caption: Environments
2022-10-03 19:01:14 +01:00
environments/classic_control
environments/box2d
2022-10-12 15:58:01 +01:00
environments/toy_text
environments/mujoco
environments/atari
2022-10-03 19:01:14 +01:00
environments/third_party_environments
2022-09-13 20:27:34 +01:00
```
```{toctree}
:hidden:
2022-10-16 14:54:03 +01:00
:glob:
2022-09-13 20:27:34 +01:00
:caption: Tutorials
2023-01-11 14:00:51 -06:00
tutorials/**/index
2023-02-01 22:30:49 +00:00
Comet Tutorial < https: / / www . comet . com / docs / v2 / integrations / ml-frameworks / gymnasium / ? utm_source = gymnasium&utm_medium=partner&utm_campaign=partner_gymnasium_2023&utm_content=docs_gymnasium >
2022-09-13 20:27:34 +01:00
```
```{toctree}
:hidden:
:caption: Development
2022-09-16 14:00:12 +01:00
Github < https: / / github . com / Farama-Foundation / Gymnasium >
2023-03-25 11:32:36 +00:00
gymnasium_release_notes/index
gym_release_notes/index
2022-10-25 11:38:43 +01:00
Contribute to the Docs < https: / / github . com / Farama-Foundation / Gymnasium / blob / main / docs / README . md >
2022-09-13 20:27:34 +01:00
```