From 82f854eb527e62150264e1554ddd94fa7b6a2989 Mon Sep 17 00:00:00 2001 From: Elliot Tower Date: Thu, 6 Jul 2023 20:03:40 -0400 Subject: [PATCH] Add basic documentation embeddign the tutorials and requirements, based on RLlib tutorials structure --- docs/tutorials/sb3/index.md | 25 +++++++++++++++++++++++ docs/tutorials/sb3/pistonball.md | 34 ++++++++++++++++++++++++++++++++ docs/tutorials/sb3/rps.md | 34 ++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 docs/tutorials/sb3/index.md create mode 100644 docs/tutorials/sb3/pistonball.md create mode 100644 docs/tutorials/sb3/rps.md diff --git a/docs/tutorials/sb3/index.md b/docs/tutorials/sb3/index.md new file mode 100644 index 000000000..dfd2ebb8f --- /dev/null +++ b/docs/tutorials/sb3/index.md @@ -0,0 +1,25 @@ +--- +title: "Stable-Baselines3" +--- + +# SB3 Tutorial + +These tutorials show you how to use [SB3](https://stable-baselines3.readthedocs.io/en/master/) to train agents in PettingZoo environments. + +* [PPO for Pistonball](/tutorials/sb3/pistonball/): _Train a PPO model in a parallel environment_ + +* [PPO for Rock-Paper-Scissors](/tutorials/sb3/rps/) _Train a PPO model in an AEC environment_ + + +```{figure} https://docs.ray.io/en/latest/_images/rllib-stack.svg + :alt: RLlib stack + :width: 80% +``` + +```{toctree} +:hidden: +:caption: RLlib + +pistonball +holdem +``` diff --git a/docs/tutorials/sb3/pistonball.md b/docs/tutorials/sb3/pistonball.md new file mode 100644 index 000000000..8e86e13e2 --- /dev/null +++ b/docs/tutorials/sb3/pistonball.md @@ -0,0 +1,34 @@ +--- +title: "SB3: PPO for Pistonball (Parallel)" +--- + +# RLlib: PPO for Pistonball + +This tutorial shows how to train a [Proximal Policy Optimization](https://stable-baselines3.readthedocs.io/en/master/modules/ppo.html) (PPO) model on the [Pistonball](https://pettingzoo.farama.org/environments/butterfly/pistonball/) environment ([parallel](https://pettingzoo.farama.org/api/parallel/)). + +After training, run the provided code to watch your trained agent play vs itself. See the [documentation](https://stable-baselines3.readthedocs.io/en/master/guide/save_format.html) for more information about saving and loading models. + + +## Environment Setup +To follow this tutorial, you will need to install the dependencies shown below. It is recommended to use a newly-created virtual environment to avoid dependency conflicts. +```{eval-rst} +.. literalinclude:: ../../../tutorials/SB3/requirements.txt + :language: text +``` + +## Code +The following code should run without any issues. The comments are designed to help you understand how to use PettingZoo with RLLib. If you have any questions, please feel free to ask in the [Discord server](https://discord.gg/nhvKkYa6qX). + +### Training the RL agent + +```{eval-rst} +.. literalinclude:: ../../../tutorials/SB3/sb3_pistonball.py + :language: python +``` + +### Watching the trained RL agent play + +```{eval-rst} +.. literalinclude:: ../../../tutorials/SB3/render_sb3_pistonball.py + :language: python +``` diff --git a/docs/tutorials/sb3/rps.md b/docs/tutorials/sb3/rps.md new file mode 100644 index 000000000..fa70d3c55 --- /dev/null +++ b/docs/tutorials/sb3/rps.md @@ -0,0 +1,34 @@ +--- +title: "SB3: PPO for Rock-Paper-Scissors (AEC)" +--- + +# RLlib: PPO for Rock-Paper-Scissors + +This tutorial shows how to train a [Proximal Policy Optimization](https://stable-baselines3.readthedocs.io/en/master/modules/ppo.html) (PPO) model on the [Pistonball](https://pettingzoo.farama.org/environments/classic/rps/) environment ([AEC](https://pettingzoo.farama.org/api/aec/)). + +After training, run the provided code to watch your trained agent play vs itself. See the [documentation](https://stable-baselines3.readthedocs.io/en/master/guide/save_format.html) for more information about saving and loading models. + + +## Environment Setup +To follow this tutorial, you will need to install the dependencies shown below. It is recommended to use a newly-created virtual environment to avoid dependency conflicts. +```{eval-rst} +.. literalinclude:: ../../../tutorials/SB3/requirements.txt + :language: text +``` + +## Code +The following code should run without any issues. The comments are designed to help you understand how to use PettingZoo with RLLib. If you have any questions, please feel free to ask in the [Discord server](https://discord.gg/nhvKkYa6qX). + +### Training the RL agent + +```{eval-rst} +.. literalinclude:: ../../../tutorials/SB3/sb3_rps.py + :language: python +``` + +### Watching the trained RL agent play + +```{eval-rst} +.. literalinclude:: ../../../tutorials/SB3/render_sb3_rps.py + :language: python +```