Game Boy simulator! Perfect operation of Super Mario, Pokemon and other games

Time:2022-1-11

Game Boy simulator! Perfect operation of Super Mario, Pokemon and other games

[introduction]: the game boy simulator based on python, Super Mario, Pokemon and other familiar games can run perfectly on it.

brief introduction

Pyboy is a game boy simulator based on python. Games such as Super Mario and Pokemon can run perfectly on it. The uniqueness of this simulator is that you can use it to create AI or robot, and let it realize automatic game clearance and other operations based on reinforcement learning.

Game Boy simulator! Perfect operation of Super Mario, Pokemon and other games

Game Boy simulator! Perfect operation of Super Mario, Pokemon and other games

Game Boy simulator! Perfect operation of Super Mario, Pokemon and other games

Game Boy simulator! Perfect operation of Super Mario, Pokemon and other games

Project address:

https://github.com/Baekalfen/…

Download and install

Python environment needs to be installed on the machine. Currently, it supports MacOS, raspberry pie, Linux (Ubuntu) and windows 10 systems.

Linux(Ubuntu)

> sudo apt update
> sudo apt install python3 python3-pip python3-dev libsdl2-dev build-essential
> python3 -m pip install --upgrade pip
> python3 -m pip install pyboy

Raspberry pie

> sudo apt update
> sudo apt install libsdl2-dev libatlas-base-dev
> python3 -m pip install --upgrade pip
> python3 -m pip install pyboy

macOS

> brew update
> brew install python3 sdl2
> python3 -m pip install --upgrade pip
> python3 -m pip install pyboy

Windows 10

Currently, only Python 3.6 and 3.7 are supported on windows. Execute the following commands in Windows PowerShell:

> (New-Object Net.WebClient).DownloadFile('https://www.python.org/ftp/python/3.7.6/python-3.7.6-amd64.exe', 'python-3.7.6-amd64.exe')
> ./python-3.7.6-amd64.exe /passive InstallAllUsers=1 PrependPath=1
> (New-Object Net.WebClient).DownloadFile('https://www.libsdl.org/release/SDL2-devel-2.0.10-VC.zip', 'SDL2-devel-2.0.10-VC.zip')
> Expand-Archive -Force 'SDL2-devel-2.0.10-VC.zip' C:\SDL2\
> setx PYSDL2_DLL_PATH C:\SDL2\SDL2-2.0.10\lib\x64
> setx PATH "%PATH%;C:\SDL2\SDL2-2.0.10\lib\x64"
//The following commands need to be reopened and executed after closing the power shell
> python -m pip install --upgrade --user pip
> python -m pip install --user pyboy

use

  1. You can start pyboy directly with the following command
pyboy file.rom

Or it can be introduced through Python script:

from pyboy import PyBoy
pyboy = PyBoy('ROMs/gamerom.gb')
while not pyboy.tick():
    pass
  1. After pyboy runs, its API can be called:
from pyboy import WindowEvent

pyboy.send_input(WindowEvent.PRESS_ARROW_DOWN)
pyboy.tick() # Process one frame to let the game register the input
pyboy.send_input(WindowEvent.RELEASE_ARROW_DOWN)

pil_image = pyboy.screen_image()
pil_image.save('screenshot.png')
  1. The following are some control commands of pyboy:

Game Boy simulator! Perfect operation of Super Mario, Pokemon and other games

Game Boy simulator! Perfect operation of Super Mario, Pokemon and other games

Open source outpostShare popular, interesting and practical open source projects on a daily basis. Participate in maintaining the open source technology resource library of 100000 + star, including python, Java, C / C + +, go, JS, CSS and node js、PHP、. Net, etc.

Recommended Today

Port isolation of HCNP Routing & Switching

Previously, we learned about RP related topics in sparse mode of multicast routing protocol. For review, please refer tohttps://www.cnblogs.com/qiuhom-1874/p/16154347.html; Today, let’s talk about VLAN isolation in layer 2 switches; We know that dividing VLAN on layer-2 switch can divide a broadcast domain into multiple broadcast domains, so as to avoid broadcast storm caused by too […]