战斗:坦克¶

此环境是 Atari 环境 的一部分。请先阅读该页面以获取一般信息。
导入 |
|
---|---|
动作 |
离散 |
Parallel API |
是 |
手动控制 |
否 |
智能体 |
|
智能体 |
2 |
动作形状 |
(1,) |
动作值 |
[0,5] |
观测形状 |
(210, 160, 3) |
观测值 |
(0,255) |
《战斗》的经典坦克模式是一款对抗游戏,预测和定位是关键。
玩家在地图上移动。当你的子弹击中对手时,你会得分。请注意,当对手被击中时,他们会被炸穿障碍物,这可能使他们处于有利位置反击你。
每当你得分时,你会被奖励 +1 分,你的对手会被惩罚 -1 分。
环境参数¶
一些环境参数对于所有 Atari 环境都是通用的,并在 基本 Atari 文档 中进行了描述。
战斗:坦克 特有的参数如下:
combat_tank_v2.env(has_maze=True, is_invisible=False, billiard_hit=True)
has_maze
: 设置为 true 时,地图会变成迷宫而非开放场地。
is_invisible
: 如果为 true,坦克将不可见,除非它们正在开火或撞墙。
billiard_hit
: 如果为 true,子弹会从墙壁弹开,实际上,就像台球一样,只有在从墙壁弹开后击中对手的坦克才算数。
动作空间¶
在任何给定的回合中,智能体可以从 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_tank_v2
env = combat_tank_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()
Parallel¶
from pettingzoo.atari import combat_tank_v2
env = combat_tank_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()