The Parallel API is designed for environments where all agents have simultaneous actions and observations, following the Partially Observable Stochastic Games (POSGs) paradigm. This is useful for environments where agents do not act in a specific turn-based order.
To create a parallel environment, use make("parallel", <game>, ...).
Note: You can use PettingZoo Wrappers to convert between Parallel and AEC environments, though AEC environments must only update once at the end of each cycle to be compatible.
from pettingzoo import make
parallel_env = make("parallel", "butterfly/pistonball-v6", render_mode="human")
observations, infos = parallel_env.reset(seed=42)
while parallel_env.agents:
# Sample actions for all active agents
actions = {agent: parallel_env.action_space(agent).sample() for agent in parallel_env.agents}
observations, rewards, terminations, truncations, infos = parallel_env.step(actions)
parallel_env.close()