Back to rankings

Baekalfen/PyBoy

Python

Game Boy emulator written in Python

gameboyemulatorpypypythongameboy-emulatorgameboy-emulator-librarycython
Star Growth
Stars
5.2k
Forks
535
Weekly Growth
Issues
17
2k4k
Jan 2016Jul 2019Jan 2023Jul 2026
ArtifactsPyPIpip install pyboy
README

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

Discord

Train RL agents to play Pokemon Red Rewind any game
Play the classics
Create your own AI
Beat world records with AI

Getting Started

The instructions are simple:

$ pip install pyboy

For details, see installation instructions.

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 Wiki 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.

Full rendering Frame-skip 15 No rendering
x124 realtime x344 realtime x395 realtime
for _ in range(target):
    pyboy.tick()
for _ in range(target//15):
    pyboy.tick(15)
pyboy.tick(target, False)

The Game Boy was originally running at 60 frames per second, so a speed-up of 100x realtime is 6,000 frames per second. And trivially from the table above, simulating 395 hours of gameplay can be done in 1 hour with no rendering.

It's also recommended to be running multiple instances of PyBoy in parallel. On an 8-core machine, you could potentially do 3160 hours of gameplay in 1 hour.

Contributing

Any contribution is appreciated. The currently known problems are tracked in the Issues tab. Feel free to take a swing at any one of them. If you have something original in mind, come and discuss it on on Discord.

Discord

For the more major features, there are the following that you can give a try. They are also described in more detail in the project list in the Wiki:

  • Hacking games
  • Link Cable
  • Debugger (VSCode, GDB, terminal or otherwise)
  • AI - use the api or game wrappers to train a neural network
  • Game Wrappers - make wrappers for popular games

If you want to implement something which is not on the list, feel free to do so anyway. If you want to merge it into our repo, then just send a pull request and we will have a look at it.

Related repositories
mgba-emu/mgba

mGBA Game Boy Advance Emulator

CMozilla Public License 2.0mgbagameboy-emulator
mgba.io
7.2k1k
Provenance-Emu/Provenance

iOS & tvOS multi-emulator frontend, supporting various Atari, Bandai, NEC, Nintendo, Sega, SNK and Sony console systems… Get Started: https://wiki.provenance-emu.com |

COtheriosemulator
provenance-emu.com
6.3k703
HFO4/gameboy.live

🕹️ A basic gameboy emulator with terminal "Cloud Gaming" support

GoGo ModulesMIT Licensegameboyemulator
4.9k243
pret/pokered

Disassembly of Pokémon Red/Blue

Assemblypokemondisassembly
4.8k1.3k
gbdev/awesome-gbdev

A curated list of Game Boy development resources such as tools, docs, emulators, related projects and open-source ROMs.

Othergameboygameboy-emulator
gbdev.io/resources
4.5k194
EmulatorJS/EmulatorJS

A web-based frontend for RetroArch

JavaScriptnpmGNU General Public License v3.0snesplaystation
emulatorjs.org
4k943
Humpheh/goboy

Multi-platform Nintendo Game Boy Color emulator written in Go

GoGo ModulesMIT Licenseemulatorgo
humpheh.github.io/goboy/
2.6k120
SourMesen/Mesen2

Multi-system emulator (NES, SNES, GB, GBA, PCE, SMS/GG, WS) for Windows, Linux and macOS

C++GNU General Public License v3.0emulatorgameboy
2.4k309
gbdk-2020/gbdk-2020

An updated version of GBDK, C compiler, assembler, linker and set of libraries for the Nintendo Gameboy, Nintendo Entertainment System, Sega Master System, Sega Game Gear.

COthergameboysdcc
2.3k144
LIJI32/SameBoy

Game Boy and Game Boy Color emulator written in C

COthergameboy-colorgameboy
sameboy.github.io
2.1k261
gbdev/rgbds

Rednex Game Boy Development System - An assembly toolchain for the Nintendo Game Boy and Game Boy Color

C++MIT Licensegameboygbdev
rgbds.gbdev.io
1.6k188
torch2424/wasmboy

Game Boy / Game Boy Color Emulator Library, 🎮written for WebAssembly using AssemblyScript. 🚀Demos built with Preact and Svelte. ⚛️

WebAssemblyGNU General Public License v3.0gameboypreact
wasmboy.app
1.5k74