Combat: 飞机¶

这个环境属于 Atari 环境系列。请先阅读该页面以获取一般信息。
导入 |
|
---|---|
动作 |
离散 |
并行 API |
是 |
手动控制 |
否 |
智能体 |
|
智能体 |
2 |
动作空间形状 |
(1,) |
动作值 |
[0,17] |
观察空间形状 |
(256, 160, 3) |
观察值 |
(0,255) |
Combat 的飞机模式是一个对抗性游戏,其中时机、位置以及跟踪对手复杂移动是关键。
玩家在地图上飞行,可以控制飞行方向但不能控制速度。
当对手被你的子弹击中时,你得分。
每当你得分时,你会获得 +1 的奖励,对手则会受到 -1 的惩罚。
环境参数¶
某些环境参数是所有 Atari 环境共有的,并在 基础 Atari 文档 中有所描述。
combat-plane 特有的参数有
combat_plane_v2.env(game_version="jet", guided_missile=True)
game_version
:接受的参数为“jet”(喷气式飞机)或“bi-plane”(双翼飞机)。表示飞机是双翼飞机还是喷气式飞机。(喷气式飞机速度更快)
guided_missile
:导弹发射后是否可以被引导,或者它是否沿固定路径飞行。
动作空间¶
在任何给定的回合中,智能体可以从 18 种动作中选择一种。
动作 |
行为 |
---|---|
0 |
无操作 |
1 |
开火 |
2 |
向上移动 |
3 |
向右移动 |
4 |
向左移动 |
5 |
向下移动 |
6 |
向右上移动 |
7 |
向左上移动 |
8 |
向右下移动 |
9 |
向左下移动 |
10 |
向上开火 |
11 |
向右开火 |
12 |
向左开火 |
13 |
向下开火 |
14 |
向右上开火 |
15 |
向左上开火 |
16 |
向右下开火 |
17 |
向左下开火 |
版本历史¶
v2:最小动作空间 (1.18.0)
v1:整个 API 的重大变化 (1.4.0)
v0:初始版本发布 (1.0.0)
用法¶
AEC¶
from pettingzoo.atari import combat_plane_v2
env = combat_plane_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 combat_plane_v2
env = combat_plane_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()