简单世界通讯

../../../_images/mpe_simple_world_comm.gif

警告

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

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

导入

from pettingzoo.mpe import simple_world_comm_v3

动作

离散/连续

Parallel API

手动控制

智能体

agents=[leadadversary_0, adversary_0, adversary_1, adversary_3, agent_0, agent_1]

智能体

6

动作空间形状

(5),(20)

动作取值

Discrete(5),(20)/Box(0.0, 1.0, (5)), Box(0.0, 1.0, (9))

观察空间形状

(28),(34)

观察取值

(-inf, inf)

状态空间形状

(192,)

状态取值

(-inf, inf)

此环境类似于 simple_tag,但增加了食物(小的蓝色球),好智能体靠近食物会获得奖励;还有“森林”,可以隐藏智能体使其不被看到;还有一个“领导对抗者”,可以随时看到所有智能体,并与其他对抗者沟通以协调追逐。默认情况下,有 2 个好智能体、3 个对抗者、1 个障碍物、2 个食物和 2 个森林。

具体来说,好智能体的奖励:每次与对抗者碰撞为 -5;根据 simple_tag 中描述的 bound 函数,边界限制为 -2;每次与食物碰撞为 +2;与任何食物的最小距离的 -0.05 倍。对抗智能体的奖励:碰撞为 +5;与好智能体的最小距离的 -0.1 倍。

好智能体观察:[self_vel, self_pos, landmark_rel_positions, other_agent_rel_positions, self_in_forest, other_agent_velocities]

普通对抗者观察:[self_vel, self_pos, landmark_rel_positions, other_agent_rel_positions, other_agent_velocities, self_in_forest, leader_comm]

对抗者领导观察:[self_vel, self_pos, landmark_rel_positions, other_agent_rel_positions, other_agent_velocities, self_in_forest, leader_comm]

请注意,当森林阻止智能体被看到时,该智能体的相对位置观察值被设置为 (0,0)。

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

普通对抗者动作空间:[no_action, move_left, move_right, move_down, move_up]

对抗者领导离散动作空间:[say_0, say_1, say_2, say_3] X [no_action, move_left, move_right, move_down, move_up]

其中 X 是笛卡尔积(总动作空间为 50)。

对抗者领导连续动作空间:[no_action, move_left, move_right, move_down, move_up, say_0, say_1, say_2, say_3]

参数

simple_world_comm_v3.env(num_good=2, num_adversaries=4, num_obstacles=1,
                num_food=2, max_cycles=25, num_forests=2, continuous_actions=False, dynamic_rescaling=False)

num_good: 好智能体的数量

num_adversaries: 对抗者的数量

num_obstacles: 障碍物的数量

num_food: 好智能体获得奖励的食物位置数量

max_cycles: 游戏结束前的帧数(每个智能体行动一步算一帧)

num_forests: 可以隐藏智能体使其不被看到的森林数量

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

dynamic_rescaling: 是否根据屏幕尺寸动态调整智能体和地标的大小

用法

AEC

from pettingzoo.mpe import simple_world_comm_v3

env = simple_world_comm_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()

Parallel

from pettingzoo.mpe import simple_world_comm_v3

env = simple_world_comm_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_world_comm.simple_world_comm.raw_env(num_good=2, num_adversaries=4, num_obstacles=1, num_food=2, max_cycles=25, num_forests=2, continuous_actions=False, render_mode=None, dynamic_rescaling=False)[source]