拳击¶

此环境属于 Atari 环境 的一部分。请先阅读该页面以获取一般信息。
导入 |
|
---|---|
动作 |
离散 |
并行 API |
是 |
手动控制 |
否 |
智能体 |
|
智能体 |
2 |
动作形状 |
(1,) |
动作值 |
[0,17] |
观测形状 |
(210, 160, 3) |
观测值 |
(0,255) |
《拳击》是一款对抗性游戏,其中精确控制和对对手的适当反应是关键。
玩家有两分钟(约 1200 步)在拳击场上对决。每一步,他们都可以移动和出拳。成功的出拳会得分,一次远距离刺拳得 1 分,一次近距离重拳得 2 分,一次 KO(击倒,也会结束游戏)得 100 分。无论何时你得分,你都会得到相应的奖励,而你的对手会受到相应的惩罚。
环境参数¶
环境参数对所有 Atari 环境都通用,并在 基础 Atari 文档 中有描述。
动作空间¶
在任何给定的回合中,智能体可以从 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 boxing_v2
env = boxing_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 boxing_v2
env = boxing_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()