1. 创建环境
env = retro.make(game='SpaceInvaders-Atari2600')
2. 初始化环境
obs = env.reset()
3. 状态空间
The size of our frame is : Box(0, 255, (210, 160, 3), uint8)
状态空间为:210*160大小,三通道的图片
4. 动作空间
The action size is : 8
动作空间为:八维
5. 动作空间编码
采用one-hot方式编码:
possible_actions = np.array(np.identity(env.action_space.n, dtype=int).tolist())
possible_actions :
[[1 0 0 0 0 0 0 0]
[0 1 0 0 0 0 0 0]
[0 0 1 0 0 0 0 0]
[0 0 0 1 0 0 0 0]
[0 0 0 0 1 0 0 0]
[0 0 0 0 0 1 0 0]
[0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 1]]
6. 运行环境
while True:
obs, rew, done, info = env.step(env.action_space.sample())
env.render()
if done:
obs = env.reset()
7. 关闭环境
env.close()