PettingZoo model environments as Agent Environment Cycle (AEC) games, in order to be able to cleanly support all types of multi-agent RL environments under one API and to minimize the potential for certain classes of common bugs.
Using environments in PettingZoo is very similar to Gymnasium, i.e. you initialize an environment via:
from pettingzoo import make
env = make("aec", "butterfly/pistonball-v6") # need to specify aec or parallel API
Environments can be interacted with in a manner very similar to Gymnasium:
env.reset()
for agent in env.agent_iter():
observation, reward, termination, truncation, info = env.last()
action = None if termination or truncation else env.action_space(agent).sample() # this is where you would insert your policy
env.step(action)
In certain environments, it's a valid to assume that agents take their actions at the same time. For these games, we offer a secondary API to allow for parallel actions, documented at https://pettingzoo.farama.org/api/parallel/
SuperSuit
SuperSuit is a library that includes all commonly used wrappers in RL (frame stacking, observation, normalization, etc.) for PettingZoo and Gymnasium environments with a nice API. We developed it in lieu of wrappers built into PettingZoo. https://github.com/Farama-Foundation/SuperSuit
Environment Versioning
PettingZoo keeps strict versioning for reproducibility reasons. All environments end in a suffix like "_v0". When changes are made to environments that might impact learning results, the number is increased by one to prevent potential confusion.
Citation
To cite this project in publication, please use
@article{terry2021pettingzoo,
title={Pettingzoo: Gym for multi-agent reinforcement learning},
author={Terry, J and Black, Benjamin and Grammel, Nathaniel and Jayakumar, Mario and Hari, Ananth and Sullivan, Ryan and Santos, Luis S and Dieffendahl, Clemens and Horsch, Caroline and Perez-Vicente, Rodrigo and others},
journal={Advances in Neural Information Processing Systems},
volume={34},
pages={15032--15043},
year={2021}
}
Maintenance for this project is also contributed by the broader Farama team: farama.org/team.
Works well with
Use together with pettingzoo: extensions, drivers, servers and companion tools.
gymnasiumPythie’s Index: 83A standard API for reinforcement learning and a diverse set of reference environments (formerly Gym).4.8M downloads/mo
ale-pyPythie’s Index: 74The Arcade Learning Environment (ALE) - a platform for AI research.235.6K downloads/mo
ShimmyPythie’s Index: 68An API conversion tool providing Gymnasium and PettingZoo bindings for popular external reinforcement learning environments.86.2K downloads/mo
skrlPythie’s Index: 64Modular and flexible library for reinforcement learning on PyTorch, JAX and NVIDIA Warp94.5K downloads/mo