Surround¶

此环境是 Atari 环境的一部分。请先阅读该页面以获取一般信息。
导入 |
|
---|---|
动作 |
离散 |
并行 API |
是 |
手动控制 |
否 |
智能体 |
|
智能体 |
2 |
动作形状 |
(1,) |
动作值 |
[0,4] |
观察形状 |
(210, 160, 3) |
观察值 |
(0,255) |
一个关于规划和策略的竞技游戏。
在 Surround 中,你的目标是避开墙壁。如果你撞到墙壁,你将被奖励 -1 分,而你的对手获得 +1 分。
但是双方玩家都会在身后留下墙壁的轨迹,慢慢用障碍物填满屏幕。为了尽可能长时间地避开障碍物,你必须规划路线以节省空间。一旦掌握了这一点,游戏就会进入更高级别的层面,双方玩家会试图用墙壁将对方包围,这样他们的对手就会用尽空间并被迫撞墙。
环境参数¶
环境参数对所有 Atari 环境都通用,并在基础 Atari 文档 中有所描述。
动作空间(最小)¶
在任何给定的回合中,智能体可以从 6 个动作中选择一个。(Fire 是一个虚拟动作,但为了连续编号)
动作 |
行为 |
---|---|
0 |
无操作 |
1 |
开火(虚拟) |
2 |
向上移动 |
3 |
向右移动 |
4 |
向左移动 |
5 |
向下移动 |
版本历史¶
v2:最小动作空间 (1.18.0)
v1:整个 API 的重大更改 (1.4.0)
v0:初始版本发布 (1.0.0)
用法¶
AEC¶
from pettingzoo.atari import surround_v2
env = surround_v2.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.atari import surround_v2
env = surround_v2.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()