Simple Push¶

警告
环境 pettingzoo.mpe.simple_push_v3 已迁移到新的 MPE2 包中,并将在未来的 PettingZoo 版本中移除。请将您的导入更新为 mpe2.simple_push_v3。
此环境是 MPE 环境的一部分。请先阅读该页面以获取一般信息。
导入 |
|
---|---|
动作 |
离散/连续 |
并行 API |
是 |
手动控制 |
否 |
智能体 |
|
智能体 |
2 |
动作空间形状 |
(5) |
动作取值 |
Discrete(5)/Box(0.0, 1.0, (5,)) |
观察空间形状 |
(8),(19) |
观察取值 |
(-inf,inf) |
状态空间形状 |
(27,) |
状态取值 |
(-inf,inf) |
此环境包含 1 个好智能体、1 个对手和 1 个地标。好智能体根据与地标的距离获得奖励。如果对手靠近地标且智能体远离地标(距离差),则对手获得奖励。因此,对手必须学会将好智能体推离地标。
智能体观察空间: [self_vel, goal_rel_position, goal_landmark_id, all_landmark_rel_positions, landmark_ids, other_agent_rel_positions]
对手观察空间: [self_vel, all_landmark_rel_positions, other_agent_rel_positions]
智能体动作空间: [no_action, move_left, move_right, move_down, move_up]
对手动作空间: [no_action, move_left, move_right, move_down, move_up]
参数¶
simple_push_v3.env(max_cycles=25, continuous_actions=False, dynamic_rescaling=False)
max_cycles
: 游戏结束前的帧数(每个智能体一步)
dynamic_rescaling
: 是否根据屏幕尺寸调整智能体和地标的大小
用法¶
AEC¶
from pettingzoo.mpe import simple_push_v3
env = simple_push_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_push_v3
env = simple_push_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()