Baekalfen/PyBoy
Fork: 474 Star: 4618 (更新于 2024-11-02 14:19:27)
license: NOASSERTION
Language: Python .
Game Boy emulator written in Python
最后发布版本: v2.4.0 ( 2024-10-07 19:01:47)
If you have any questions, or just want to chat, join us on 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 |
|
|
|
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.
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.
最近版本更新:(数据更新于 2024-11-02 14:19:12)
2024-10-07 19:01:47 v2.4.0
2024-09-15 04:07:28 v2.3.0
2024-07-14 01:18:12 v2.2.2
2024-07-03 08:30:58 v2.2.1
2024-06-13 02:43:26 v2.2.0
2024-05-27 15:48:45 v2.1.0
2024-04-22 17:00:37 v2.0.3
2024-04-19 00:03:10 v2.0.2
2024-03-21 15:48:51 v2.0.1
2024-03-17 19:55:37 v2.0.0
主题(topics):
cython, emulator, gameboy, gameboy-emulator, gameboy-emulator-library, pypy, python
Baekalfen/PyBoy同语言 Python最近更新仓库
2024-11-22 00:03:47 comfyanonymous/ComfyUI
2024-11-21 22:06:18 rashevskyv/dbi
2024-11-21 21:09:02 xtekky/gpt4free
2024-11-21 20:03:58 ultralytics/ultralytics
2024-11-21 00:54:04 hect0x7/JMComic-Crawler-Python
2024-11-20 20:44:58 jxxghp/MoviePilot