Package: pettingzoo
PettingZoo is a Python library for conducting research in multi-agent reinforcement learning, akin to a multi-agent version ofGymnasium.The documentation website is atpettingzoo.farama.organd we have a public discord server (which we also use to coordinate development work) that you can join here:https://discord.gg/nhvKkYa6qXEnvironmentsPettingZoo includes the following families of environments:Atari: Multi-player Atari 2600 games (cooperative, competitive and mixed sum)Butterfly: Cooperative graphical games developed by us, requiring a high degree of coordinationClassic: Classical games including card games, board games, etc.MPE: A set of simple nongraphical communication tasks, originally fromhttps://github.com/openai/multiagent-particle-envsSISL: 3 cooperative environments, originally fromhttps://github.com/sisl/MADRLInstallationTo install the base PettingZoo library:pip install pettingzoo.This does not include dependencies for all families of environments (some environments can be problematic to install on certain systems).To install the dependencies for one family, usepip install 'pettingzoo[atari]', or usepip install 'pettingzoo[all]'to install all dependencies.We support Python 3.8, 3.9, 3.10 and 3.11 on Linux and macOS. We will accept PRs related to Windows, but do not officially support it.Getting startedFor an introduction to PettingZoo, seeBasic Usage. To create a new environment, see ourEnvironment Creation TutorialandCustom Environment Examples.
For examples of training RL models using PettingZoo see our tutorials:CleanRL: Implementing PPO: train multiple PPO agents in thePistonballenvironment.Tianshou: Training Agents: train DQN agents in theTic-Tac-Toeenvironment.AgileRL: Training, Curriculums and Self-play: train agents with curriculum learning and self-play in theConnect Fourenvironment.APIPettingZoo model environments asAgent 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:frompettingzoo.butterflyimportpistonball_v6env=pistonball_v6.env()Environments can be interacted with in a manner very similar to Gymnasium:env.reset()foragentinenv.agent_iter():observation,reward,termination,truncation,info=env.last()action=Noneifterminationortruncationelseenv.action_space(agent).sample()# this is where you would insert your policyenv.step(action)For the complete API documentation, please seehttps://pettingzoo.farama.org/api/aec/Parallel APIIn 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 athttps://pettingzoo.farama.org/api/parallel/SuperSuitSuperSuit 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/SuperSuitEnvironment VersioningPettingZoo 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.Project MaintainersProject Manager:Elliot TowerMaintenance for this project is also contributed by the broader Farama team:farama.org/team.CitationTo 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}
}