开放式健身房俄罗斯方块
gym-tetris的Python项目详细描述
体育俄罗斯方块
俄罗斯方块的OpenAI Gym环境 基于 nes-py模拟器。
安装
gym-tetris
的首选安装位置是pip
:
pip install gym-tetris
用法
Python
在尝试创建环境之前,必须导入gym_tetris
。
这是因为健身房环境是在运行时注册的。默认情况下,
gym_tetris
环境使用完整的NES操作空间256
离散动作。为了限制这种情况,gym_tetris.actions
提供
一个名为MOVEMENT
(20个离散操作)的操作列表,用于
nes_py.wrappers.JoypadSpace
包装。还有
SIMPLE_MOVEMENT
减少了操作空间(6个操作)。具体细节,
见gym_tetris/actions.py。
fromnes_py.wrappersimportJoypadSpaceimportgym_tetrisfromgym_tetris.actionsimportMOVEMENTenv=gym_tetris.make('Tetris-v0')env=JoypadSpace(env,MOVEMENT)done=Trueforstepinrange(5000):ifdone:state=env.reset()state,reward,done,info=env.step(env.action_space.sample())env.render()env.close()
注意:gym_tetris.make
只是gym.make
的别名
方便。
注意:删除训练代码中对render
的调用
加速。
命令行
gym_tetris
具有用于播放的命令行界面
使用键盘或均匀随机移动的环境。
gym_tetris -e <environment ID> -m <`human` or `random`>
环境
东北俄罗斯方块有两种游戏模式,即A型和B型。 A-type是标准的耐力俄罗斯方块游戏,B-type是街机风格的模式 代理人必须清除一定数量的行才能获胜。有三个 潜在的奖励流:(1)得分的变化,(2)数量的变化 线被清除,以及(3)增加板高的罚款。桌子 下面根据游戏模式定义了可用的环境(即, A型或B型)和所申请的奖励。
Environment | Game Mode | reward score | reward lines | penalize height |
---|---|---|---|---|
^{ | A-type | ✅ | ✕ | ✕ |
^{ | A-type | ✕ | ✅ | ✕ |
^{ | A-type | ✅ | ✕ | ✅ |
^{ | A-type | ✕ | ✅ | ✅ |
^{ | B-type | ✅ | ✕ | ✕ |
^{ | B-type | ✕ | ✅ | ✕ |
^{ | B-type | ✅ | ✕ | ✅ |
^{ | B-type | ✕ | ✅ | ✅ |
info
字典
由step
方法返回的info
字典包含以下内容
按键:
Key | Type | Description |
---|---|---|
^{ | ^{ | the current piece as a string |
^{ | ^{ | the number of cleared lines |
^{ | ^{ | the current score of the game |
^{ | ^{ | the next piece on deck |
^{ | ^{ | statistics for each piece |
引文
如果你在研究中使用它,请引用gym-tetris
。
@misc{gym-tetris, author = {Christian Kauten}, title = {{Tetris (NES)} for {OpenAI Gym}}, year = {2019}, publisher = {GitHub}, howpublished = {\url{https://github.com/Kautenja/gym-tetris}}, }
参考文献
以下参考资料有助于本项目的建设。
- Tetris (NES): RAM Map。data crystal rom黑客攻击。
- Tetris: Memory Addresses。nes黑客。
- Applying Artificial Intelligence to Nintendo Tetris。肉食斗士。