一个多智能体强化学习的 API 标准。

_images/environments-demo.gif

PettingZoo 是一个简单、符合 Python 风格的接口,能够表示通用的多智能体强化学习 (MARL) 问题。 PettingZoo 包含各种各样的参考环境、实用的工具和创建自定义环境的工具。

用于顺序回合制环境的 AEC API,以及用于并行行动环境的 Parallel API

可以使用类似于 Gymnasium 的接口与环境进行交互。

from pettingzoo.butterfly import knights_archers_zombies_v10
env = knights_archers_zombies_v10.env(render_mode="human")
env.reset(seed=42)

for agent in env.agent_iter():
    observation, reward, termination, truncation, info = env.last()

    if termination or truncation:
        action = None
    else:
        # this is where you would insert your policy
        action = env.action_space(agent).sample()

    env.step(action)