Simple¶

警告
环境 pettingzoo.mpe.simple_v3 已被移至新的 MPE2 包,并将在未来的 PettingZoo 版本中移除。请将导入更新为 mpe2.simple_v3。
此环境是 MPE 环境的一部分。请先阅读该页面以获取一般信息。
导入 |
|
---|---|
动作 |
离散/连续 |
Parallel API |
是 |
手动控制 |
否 |
智能体 |
|
智能体 |
1 |
动作形状 |
(5) |
动作值 |
Discrete(5)/Box(0.0, 1.0, (5,)) |
观察形状 |
(4) |
观察值 |
(-inf,inf) |
状态形状 |
(4,) |
状态值 |
(-inf,inf) |
在此环境中,单个智能体看到一个地标位置,并根据它与地标的接近程度(欧氏距离)获得奖励。这不是一个多智能体环境,主要用于调试目的。
观察空间:[self_vel, landmark_rel_position]
参数¶
simple_v3.env(max_cycles=25, continuous_actions=False, dynamic_rescaling=False)
max_cycles
:直到游戏终止的帧数(每个智能体的一个步长)
continuous_actions
:智能体动作空间是离散(默认)还是连续
dynamic_rescaling
:是否根据屏幕大小重新缩放智能体和地标的大小
用法¶
AEC¶
from pettingzoo.mpe import simple_v3
env = simple_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_v3
env = simple_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()