Pong

../../../_images/atari_pong.gif

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

导入

from pettingzoo.atari import pong_v3

动作

离散

Parallel API

手动控制

智能体

agents= ['first_0', 'second_0']

智能体

2

动作形状

(1,)

动作值

[0,5]

观察形状

(210, 160, 3)

观察值

(0,255)

经典的双人竞技时机游戏。

将球打过对手。

得一分您将获得 +1 奖励,您的对手将获得 -1 奖励。

发球计时:如果玩家在接到球后 2 秒内没有发球,他们将获得 -1 分,并且计时器重置。这防止了一方无限期地拖延比赛,但也意味着它不再是一个纯粹的零和游戏。

官方 Video Olympics 手册

环境参数

一些环境参数是所有 Atari 环境共有的,并在Atari 基础文档中进行了描述。

Pong 特有的参数有

pong_v3.env(num_players=2)

num_players:玩家数量(必须是 2 或 4)

动作空间(最小)

在任何一个回合中,智能体可以从 6 个动作中选择一个。

动作

行为

0

无操作

1

发射

2

向右移动

3

向左移动

4

向右发射

5

向左发射

版本历史

  • v3:最小动作空间 (1.18.0)

  • v2:无动作计时器 (1.9.0)

  • v1:整个 API 的破坏性更改 (1.4.0)

  • v0:初始版本发布 (1.0.0)

用法

AEC

from pettingzoo.atari import pong_v3

env = pong_v3.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 pong_v3

env = pong_v3.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.pong.pong.raw_env(num_players=2, game_version='classic', **kwargs)[source]