[introduction]: the game boy simulator based on python, Super Mario, Pokemon and other familiar games can run perfectly on it.
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.
Download and install
Python environment needs to be installed on the machine. Currently, it supports MacOS, raspberry pie, Linux (Ubuntu) and windows 10 systems.
> 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
> sudo apt update > sudo apt install libsdl2-dev libatlas-base-dev > python3 -m pip install --upgrade pip > python3 -m pip install pyboy
> brew update > brew install python3 sdl2 > python3 -m pip install --upgrade pip > python3 -m pip install pyboy
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
- You can start pyboy directly with the following command
Or it can be introduced through Python script:
from pyboy import PyBoy pyboy = PyBoy('ROMs/gamerom.gb') while not pyboy.tick(): pass
- 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')
- The following are some control commands of pyboy:
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.