Custom Gymnasium Environments
gym.Env subclass, observation/action spaces, step/reset/render, registering custom env.
What is Gymnasium?
Gymnasium (the maintained successor to OpenAI Gym) is the standard API for RL environments. Any agent that follows its interface works with any compatible environment, so building your own unlocks RL for custom problems.
pip install gymnasium
import gymnasium as gymSubclassing gymnasium.Env
A custom environment subclasses gymnasium.Env and implements four things: the action and observation spaces, plus reset and step. That contract is all an agent needs.
class GridWorld(gym.Env):
def __init__(self):
super().__init__()All lessons in this course
- Policy Gradient Methods: REINFORCE
- Actor-Critic Methods (A2C)
- Proximal Policy Optimization (PPO)
- Custom Gymnasium Environments