(Neural)-Zero X is an AI that can play F-Zero X on BizHawk emulator using real time CNNs. This repository is part of a Universidad de Sevilla's final degree project.
To run this project, you need Python 3 and Bizhawk emulator.
This project was written for Python 3.7. Tensorflow requires 64-bit Python.
The following Python dependencies need to be installed.
- Tensorflow 2.2.0
- Keras 2.3.1
- Pillow
- matplotlib
- mkdir_p
- h5py
Although you can run Tensorflow on CPU, I'll recommend you to download and install TensorFlow GPU dependencies too.
TensorFlow | Python | cuDNN | CUDA |
---|---|---|---|
2.2.0 | 3.5 to 3.8 | 7.6 | 10.1 |
This project contains LUA script files ready to run on BizHawk emulator (tested on version 2.6.2). To get BizHawk you first need to install the prerequisites. Then you can download BizHawk and unzip it to any directory.
You will also need a F-Zero X ROM to run on BizHawk emulator.
Download this data to run the demo. You can also download my recordings to train the models by yourself. These should be unzipped into the folder of this repository.
- Save States - LUA scripts will access the saved states on
states/[file].state
. - Weights - Python scripts will access the trained models on
weights/[model].hdf5
- Recordings (Optional) - The recordings should be accessible as
recordings/[recording]/[frame].png
.
Recordings file is almost 1GB. It contains >12000 game samples as screenshots.
You must run .py files directly from console and .lua files from BizHaw Lua Console. You can find all lua files on scripts
folder.
These instructions can be used to run a demo on Mute City using the demo
model.
- Download the save states and pre-trained model.
- Run
predict-server.py
using Python - this starts a server on port36296
which actually runs the model.- You must specify the model you want to run. Use
demo
as first parameter. - You can pass a
--cpu
to force Tensorflow to run on the CPU.
- You must specify the model you want to run. Use
- Open BizHawk and load a F-Zero X ROM.
- Turn off messages (View > Display Messages).
- You don't have to do this, but they get in the way.
- Open the BizHawk Lua console (Tools > Lua Console).
- Load
Demo.lua
This should automatically play Mute City time attack race. You can hit the arrow keys to manually steer the Blue Falcon. This can be used to demonstrate the AI's stability.
The first thing you need to train your model is training data. You can generate training data using Record.lua
and RecordImput.lua
.
- Open BizHawk and load a F-Zero X ROM.
- Open the BizHawk Lua console (Tools > Lua Console).
- Load
RecordImput.lua
- Play for a while (I'll recommend to use a joystick or game controller)
A new folder will be created on recordings
. A screenshot will be stored everytime you move the joystick playing the game with the imput value stored on steering.txt
Once you have generated new recording, you probably want to try retraining the weights based off your recordings. To train a new model, run train.py [model]
. You can also use --cpu
to force it to use the CPU. Your trained model will be stored on weights/[model].hdf5
You can include train data from train.zip along your own recordings.
You can load the race savestate from states/MuteCityGP.state
to test your new trained model.
Remember to launch predict-server.py
first and load Play.lua
from Lua console.
You can use Record.lua
and RecordImput.lua
to generate training data for another track. Even for another game!
Remember to use a different name as parameter when you train your model with train.py
.
- NeuralKart - This project was forked from rameshvarun real time Mario Kart AI.
- TensorKart - The first MarioKart deep learning project, used for reference.