Skip to content

Commit

Permalink
Add basic documentation embeddign the tutorials and requirements, bas…
Browse files Browse the repository at this point in the history
…ed on RLlib tutorials structure
  • Loading branch information
elliottower committed Jul 7, 2023
1 parent 9655ead commit 82f854e
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
25 changes: 25 additions & 0 deletions docs/tutorials/sb3/index.md
Original file line number Diff line number Diff line change
@@ -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
```
34 changes: 34 additions & 0 deletions docs/tutorials/sb3/pistonball.md
Original file line number Diff line number Diff line change
@@ -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
```
34 changes: 34 additions & 0 deletions docs/tutorials/sb3/rps.md
Original file line number Diff line number Diff line change
@@ -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
```

0 comments on commit 82f854e

Please sign in to comment.