Baekalfen/PyBoy

Public

Game Boy emulator written in Python

  • Stars5.2k+5 tuần này
  • Forks543
  • Watchers76
  • Issues7
  • Ngày tạo29/05/2015
  • Cập nhật gần nhất22/10/2026
  • Ngôn ngữPython
  • Giấy phép—
README.md11.4 KBRaw

If you have any questions, or just want to chat, join us on Discord.

Baekalfen%2FPyBoy | Trendshift

Train RL agents to play Pokemon Red Rewind any game
Play the classics
Create your own AI
Teach Mario to win

Getting Started

The instructions are simple:

$ pip install pyboy

For platform-specific instructions, see the installation guide.

Now you're ready! Either use PyBoy directly from the terminal

$ pyboy game_rom.gb

Or use it in your Python scripts:

from pyboy import PyBoy
pyboy = PyBoy('game_rom.gb')
while pyboy.tick():
    pass
pyboy.stop()

The API

If you are looking to make a bot or AI, then these resources are a good place to start:

When the emulator is running, you can easily access PyBoy's API:

pyboy.set_emulation_speed(0) # No speed limit
pyboy.button('down')
pyboy.button('a')
pyboy.tick() # Process at least one frame to let the game register the input
value_of_interest = pyboy.memory[0xC345]

pil_image = pyboy.screen.image
pil_image.save('screenshot.png')

The documentation homepage shows how to interface with PyBoy from your own project.

Performance

Performance is a priority for PyBoy, to make your AI training and scripts as fast as possible.

The easiest way to improve your performance, is to skip rendering of unnecessary frames. If you know your character takes X frames to move, or the game doesn't take input every frame, you can skip those to potentially triple your performance. All game logic etc. will still process.

Here is a simple comparison of rendering every frame, rendering every 15th frame, and not rendering any frames (higher is better). See pyboy.tick for how it works. Your performance will depend on the game.

Nội dung README thuộc về Baekalfen và cộng đồng đóng góp, giấy phép Không có giấy phép. Nguồn: github.com/Baekalfen/PyBoy