简单对手

../../../_images/mpe_simple_adversary.gif

警告

环境 pettingzoo.mpe.simple_adversary_v3 已移至新的 MPE2 包中,并将在未来的 PettingZoo 版本中移除。请更新您的导入语句为 mpe2.simple_adversary_v3

此环境是 MPE 环境 的一部分。请先阅读该页面以获取通用信息。

导入

from pettingzoo.mpe import simple_adversary_v3

动作

离散/连续

并行 API

手动控制

智能体

agents= [adversary_0, agent_0,agent_1]

智能体

3

动作空间形状

(5)

动作值

离散(5)/Box(0.0, 1.0, (5))

观察空间形状

(8),(10)

观察值

(-inf, inf)

状态空间形状

(28,)

状态值

(-inf, inf)

在此环境中,有 1 个对手(红色)、N 个好智能体(绿色)、N 个地标(默认为 N=2)。所有智能体都能观察到地标和其他智能体的位置。其中一个地标是“目标地标”(绿色)。好智能体的奖励取决于它们中最接近目标地标的那个与目标地标的距离,而其惩罚取决于对手与目标地标的距离。对手的奖励基于其与目标的距离,但它不知道哪个是目标地标。所有奖励都是未缩放的欧几里得距离(有关平均距离,请参阅主要的 MPE 文档)。这意味着好智能体必须学会“分散”并覆盖所有地标,以欺骗对手。

智能体观察空间:[goal_rel_position, landmark_rel_position, other_agent_rel_positions]

对手观察空间:[landmark_rel_position, other_agents_rel_positions]

智能体动作空间:[no_action, move_left, move_right, move_down, move_up]

对手动作空间:[no_action, move_left, move_right, move_down, move_up]

参数

simple_adversary_v3.env(N=2, max_cycles=25, continuous_actions=False, dynamic_rescaling=False)

N:好智能体和地标的数量

max_cycles:游戏终止前的帧数(每个智能体的一步)

continuous_actions:智能体动作空间是离散(默认)还是连续

dynamic_rescaling:是否根据屏幕尺寸缩放智能体和地标的大小

用法

AEC

from pettingzoo.mpe import simple_adversary_v3

env = simple_adversary_v3.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)
env.close()

并行

from pettingzoo.mpe import simple_adversary_v3

env = simple_adversary_v3.parallel_env(render_mode="human")
observations, infos = env.reset()

while env.agents:
    # this is where you would insert your policy
    actions = {agent: env.action_space(agent).sample() for agent in env.agents}

    observations, rewards, terminations, truncations, infos = env.step(actions)
env.close()

API

class pettingzoo.mpe.simple_adversary.simple_adversary.raw_env(N=2, max_cycles=25, continuous_actions=False, render_mode=None, dynamic_rescaling=False)[源码]