self-driving Mario Kart 8 Deluxe with TensorFlow
python
andpip
then runpip install -r requirements.txt
yuzu
- Start your emulator program (
yuzu
) and run Mario Kart 8 Deluxe - Make sure you have a joystick connected
- Run
record.py
- Make sure the graph responds to joystick input.
- Position the emulator window so that the image is captured by the program (top left corner)
- Press record and play through a level. You can trim some images off the front and back of the data you collect afterwards (by removing lines in
data.csv
).
Notes
- the GUI will stop updating while recording to avoid any slow downs.
- double check the samples, sometimes the screenshot is the desktop instead. Remove the appropriate lines from the
data.csv
file
Run python utils.py viewer samples/your_sample
to view the samples
Run python utils.py prepare samples/*
with an array of sample directories to build an X
and y
matrix for training. (zsh will expand samples/* to all the directories. Passing a glob directly also works)
X
is a 3-Dimensional array of images
y
is the expected joystick ouput as an array:
[0] joystick x axis
The train.py
program will train a model using Google's TensorFlow framework and cuDNN for GPU acceleration. Training can take a while (~1 hour) depending on how much data you are training with and your system specs. The program will save the model to disk when it is done.
The play.py
program will use vjoy
to control the game on yuzu. The programm will provide the screenshots of the emulator. These images will be sent to the model to acquire the joystick command to send. The AI joystick commands can be overridden by holding the 'LB' button on the controller.