Skip to content

How to create a custom Gymnasium-compatible (formerly, OpenAI Gym) Reinforcement Learning environment. Then test it using Q-Learning and the Stable Baselines3 library. Companion YouTube tutorial playlist:

License

Notifications You must be signed in to change notification settings

johnnycode8/gym_custom_env

Repository files navigation

Gymnasium Custom Reinforcement Learning Environments

Tutorials on how to create custom Gymnasium-compatible Reinforcement Learning environments using the Gymnasium Library, formerly OpenAI’s Gym library. Each tutorial has a companion video explanation and code walkthrough from my YouTube channel @johnnycode. If the code and video helped you, please consider:
Buy Me A Coffee

Custom Gym Environment part 1 - Warehouse Robot v0

This is a very basic tutorial showing end-to-end how to create a custom Gymnasium-compatible Reinforcement Learning environment. The tutorial is divided into three parts:

  1. Model your problem.
  2. Convert your problem into a Gymnasium-compatible environment.
  3. Train your custom environment in two ways; using Q-Learning and using the Stable Baselines3 library.
Code Reference:
  • v0_warehouse_robot*.py
YouTube Tutorial:

Build Custom Gymnasium Env

Custom Gym Environment part 2 - Visualization with Pygame

In part 1, we created a very simple custom Reinforcement Learning environment that is compatible with Farama Gymnasium (formerly OpenAI Gym). In this tutorial, we'll do a minor upgrade and visualize our environment using Pygame.

Code Reference:
  • v0_warehouse_robot*.py
YouTube Tutorial:

Build Custom Gymnasium Env with Pygame

Additional Resources

How gymnasium.spaces.Box Works

The Box space type is used in many Gymnasium environments and you'll likely need it for your custom environment. The Box action space can be used to validate agent actions or generate random actions. The Box observation space can be used to validate the environment's state. This video explains and demos how to create boxes of different sizes/shapes, lower (low) and upper (high) boundaries, and as int/float data types.

YouTube Tutorial:

How gymnasium.spaces.Box Works

Reinforcement Learning Tutorials

For more Reinforcement Learning and Deep Reinforcement Learning tutorials, check out my Gym Solutions repository.

(back to top)

About

How to create a custom Gymnasium-compatible (formerly, OpenAI Gym) Reinforcement Learning environment. Then test it using Q-Learning and the Stable Baselines3 library. Companion YouTube tutorial playlist:

Resources

License

Stars

Watchers

Forks