太空大战

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

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

导入

pettingzoo.atari 导入 space_war_v2

动作

离散

Parallel API

手动控制

智能体

agents= ['first_0', 'second_0']

智能体

2

动作形状

(1,)

动作值

[0,17]

观察形状

(250, 160, 3)

观察值

(0,255)

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

玩家在地图上移动。当你的子弹击中对手时,你会得分。游戏类似于战斗,但具有更先进的物理系统,需要考虑加速度和动量。

每当你得分时,你会获得 +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()

Parallel

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

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