All the Things You Need to Know about Gym

Basics

OpenAI Gym is a toolkit for developing and comparing reinforcement learning algorithms.

For reinforcement learning problem, two part:

  • the environment
  • the agent

The core gym interface is Env, which is the unified environment interface. There is no interface for agents:

  • reset(self): Reset the environment’s state. Returns observation.
  • step(self, action): Step the environment by one timestep. Returns observation, reward, done, info.
  • render(self, mode=‘human’): Render one frame of the environment. The default mode will do something human friendly, such as pop up a window.

Supported Environment

Included Environment

  • Algorithmic
  • Atari
  • Box2d
  • Classic control
  • Robotics
  • MuJoCo
  • Toy Text

OpenAI Environment

  • Procgen
  • Gym-Retro

Third Party Environments

  • PyBullet Robotics Environments
  • Obstacle Tower
  • gym-maze
  • gym-gazebo
  • osim-rl
  • gym-minigrid & gym-miniworld
  • gym-sokoban
  • gym-duckietown
  • gymfc
  • gym-anytrading
  • GymGo
  • gym-electric-motor

Creating Your Own Environment

The most important thing is to keep the architecture of your package like this:

  gym-foo/
    README.md
    setup.py
    gym_foo/
      __init__.py
      envs/
        __init__.py
        foo_env.py
        foo_extra_hard_env.py

See more in Create new environment for Gym.

Wrappers

Wrappers are list of general purpose wrappers for environments. These can perform pre/postprocessing on the data that is exchanged between the agent and the environment.

There are many wrappers which you can use to transform the observation and/or action spaces and do some other operations.

Agents

An “agent” describes the method of running an RL algorithm against an environment in the gym.

  • RandomAgent: This simple agent leverages the environments ability to produce a random valid action and does so for each step.
  • Cross-Enrorpy Agent
  • DQN
  • AgentNet
  • rllab
  • keras-rl

Note: Cover Picture