太空大战

../../../_images/atari_space_war.gif

此环境是 Atari 环境的一部分。请先阅读该页面以获取一般信息。

导入

from pettingzoo.atari import space_war_v2

动作

离散

并行 API

手动控制

智能体

agents= ['first_0', 'second_0']

智能体

2

动作空间形状

(1,)

动作取值

[0,17]

观测空间形状

(250, 160, 3)

观测取值

(0,255)

太空大战是一款竞争性游戏,预测和定位是关键。

玩家在地图上移动。当你的子弹击中对手时,你得分。该游戏与 combat 类似,但具有更高级的物理系统,需要考虑加速度和动量。

每当你得分时,你会获得 +1 的奖励,你的对手会受到 -1 的惩罚。

官方太空大战手册

环境参数

环境参数是所有 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 space_war_v2

env = space_war_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 space_war_v2

env = space_war_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()

API

class pettingzoo.atari.space_war.space_war.raw_env(**kwargs)[source]