explaingit

openai/gym

Analysis updated 2026-06-20

37,181PythonAudience · researcherComplexity · 3/5LicenseSetup · moderate

TLDR

A standard toolkit of simulated game and physics environments for teaching AI agents through trial and reward. Now superseded by Gymnasium, use this repo only for legacy projects.

Mindmap

mindmap
  root((OpenAI Gym))
    What it does
      Simulated environments
      Standard RL interface
      Algorithm testing
    Tech stack
      Python 3.7 to 3.10
      MuJoCo physics
    Environment types
      Atari games
      Pole balancing
      Robotics sims
      Grid worlds
    Status
      No longer maintained
      Succeeded by Gymnasium
    Audience
      AI researchers
      ML developers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Test a reinforcement learning algorithm across many different environments without rewriting code

USE CASE 2

Run or reproduce older AI research experiments that depend on the Gym API

USE CASE 3

Learn the basics of how AI agents are trained through simulated trial and reward

USE CASE 4

Benchmark and compare different learning strategies using standard environments like Atari games

What is it built with?

PythonMuJoCo

How does it compare?

openai/gym0voice/interview_internal_referencesqlmapproject/sqlmap
Stars37,18137,22537,268
LanguagePythonPythonPython
Setup difficultymoderateeasyeasy
Complexity3/51/53/5
Audienceresearcherdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Requires Python 3.7, 3.10. Some environments need MuJoCo. For new projects, install Gymnasium instead: pip install gymnasium.

Open-source, free to use and modify for research and development.

In plain English

OpenAI Gym is a Python toolkit that provides a standard set of simulated environments for developing and testing reinforcement learning algorithms. Reinforcement learning is a branch of AI where an agent learns by taking actions in an environment and receiving rewards or penalties, the goal is to learn a strategy that maximizes cumulative rewards over time. The problem Gym solves is that building such environments from scratch for every experiment is time-consuming, and without a common interface, it is hard to compare different algorithms fairly. Gym defines a simple, consistent API: every environment has a step function (take an action, get back the new state and a reward), a reset function (start fresh), and an observation space and action space describing what the agent can see and do. Researchers or developers implement their learning algorithm once against this interface, then swap in different environments without changing their code. The library shipped with a wide variety of built-in environments, classic control tasks like balancing a pole on a cart, Atari video game simulators, physics-based robotics simulations using the MuJoCo physics engine, and simple grid worlds. Note from the README: Gym itself is no longer actively maintained. The team that maintained it since 2021 has moved all future development to a successor project called Gymnasium (by the Farama Foundation), which is a drop-in replacement. If you are starting a new project, the README explicitly recommends switching to Gymnasium instead. You would use the original Gym repository to run older code that depends on it, or to understand the history of the reinforcement learning API standard. The tech stack is Python, compatible with versions 3.7 through 3.10 on Linux and macOS.

Copy-paste prompts

Prompt 1
Show me how to set up a basic reinforcement learning loop using OpenAI Gym's CartPole environment in Python.
Prompt 2
How do I write a simple Q-learning agent that trains on an OpenAI Gym environment?
Prompt 3
I have old code that uses openai/gym, what's the minimum change needed to migrate it to Gymnasium?
Prompt 4
How do I create a custom Gym-compatible environment with its own observation space and reward function?

Frequently asked questions

What is gym?

A standard toolkit of simulated game and physics environments for teaching AI agents through trial and reward. Now superseded by Gymnasium, use this repo only for legacy projects.

What language is gym written in?

Mainly Python. The stack also includes Python, MuJoCo.

What license does gym use?

Open-source, free to use and modify for research and development.

How hard is gym to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is gym for?

Mainly researcher.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub openai on gitmyhub

Verify against the repo before relying on details.