目录
1. PyBoy 简介
2. 安装与使用
3. Demo测试
4. 常用 API 接口
4.1. set_emulation_speed(模拟速度控制)
4.2. cartridge_title(返回 ROM 的内部标题)
4.3. game_wrapper
4.4. send_input(模拟输入)
4.5. tick(下一帧)
4.6. stop
1. PyBoy 简介
PyBoy 是一个基于 Python 的 Game Boy 模拟器,作者是哥本哈根大学一名学生 Mads Ynddal。这款模拟器可用来创建 AI 或机器人,让它基于强化学习实现自动打游戏通关等骚操作。像超级马里奥、口袋妖怪等耳熟能详的游戏都可以在上面完美运行。
2. 安装与使用
pip install pysdl2-dll -i https://pypi.douban.com/simple
pip install pybody -i https://pypi.douban.com/simple
3. Demo测试
from pyboy import PyBoy
pyboy = PyBoy('roms/Super Mario Land (JUE) (V1.1) [!].gb')
while not pyboy.tick():
pass
4. 常用 API 接口
4.1. set_emulation_speed(模拟速度控制)
图4-1:4 倍速效果
4.2. cartridge_title(返回 ROM 的内部标题)
4.3. game_wrapper
4.4. send_input(模拟输入)
from pyboy import PyBoy, WindowEvent
pyboy = PyBoy('roms/Super Mario Land (JUE) (V1.1) [!].gb')
pyboy.set_emulation_speed(1)
print(pyboy.cartridge_title())
while not pyboy.tick():
pyboy.send_input(WindowEvent.PRESS_ARROW_RIGHT)
pass
4.5. tick(下一帧)
4.6. stop
参考:
BGB: http://bgb.bircd.org/ PyBoy: https://github.com/Baekalfen/PyBoy PySDL2: https://pysdl2.readthedocs.io/en/rel_0_9_7/index.html# Super-Mario-Land-AI: https://github.com/octavio-santiago/Super-Mario-Land-AI