NeuroBlast is a classic arcade space shooter with ML-powered AI using TensorFlow. In this short demo intended to demonstrate the accessibility of open source tools for machine learning, you can train an enemy AI using machine learning.
If you want to learn more about how the game works under the hood, and for a tour of the insides, see these two blog posts:
- Building an ML-Powered AI Using TensorFlow in Go on GopherData.io
- Building Game AI Using Machine Learning: Working With TensorFlow, Keras, and the Intel MKL in Python
You can also watch my GopherCon 2017 Lightning talk about the game or view the slides.
Before you start, you will require the following external libraries/tools:
- Python 3.5 or Go 1.8
- MongoDB server Download
- TensorFlow C libraries for Go version Instructions
Note: TensorFlow for Go is only available of macOS/Linux. Windows is NOT supported.
For any package dependencies, you can either install them via pip/dep or you can also install ActivePython 3.5.3 or ActiveGo 1.8 to have an environment with nearly all dependencies already pre-installed.
To setup the game to run on Windows in Python 3:
git clone https://github.com/ActiveState/neuroblast.git
pip3 install -r requirements.txt
- Launch
rungame.cmd
(which will launch the Mongo server).
To setup the game to run on MacOS/Linux in Python 3:
git clone https://github.com/ActiveState/neuroblast.git
cd neuroblast
mkdir db
pip3 install -r requirements.txt
- Launch Mongo server:
mongod --dbpath ./db
- Launch the game
python3 game.py
Note: If you previously had Keras installed on your machine, and had run it using a different backend, make sure you configure your Keras backend to run using TensorFlow by following these instructions.
To setup the game to run on MacOS/Linux in Go 1.8:
Reminder: You must have the TensorFlow C libraries installed as per these instructions.
Note: You must clone the repo into your GOPATH, or add the folder you clone into to your GOPATH in order for dep ensure
to work.
git clone https://github.com/ActiveState/neuroblast.git
cd go
dep ensure
go build
- Launch the game
./go
There are a number of options available when running the game from Python:
-n
changes the Neural Network model from using TensorFlow to using the "home grown" network model which is useful for prototyping/debugging.-f
launches the game in full screen.-v
changes the visualization method to use raw Keras/TensorFlow values. Warning: This is much slower!
Note: These options are not available in the Go version.
Control your ship with the arrow keys or the left-analog stick with a gamepad.
Use either SPACE
or the A button on your gamepad to fire. You can hold the button down for continuous fire.
On the main menu of the Python version, you can use the following commands to export debug data:
x
- Exports a model using the SavedModelBuilder functionality to use in the Go version
w
- Exports weights.csv which are the trained weights of the current model
d
- Exports traindata.csv which is a dump of the training data points currently in memory
- Collision is not pixel-perfect
- In the Python version, being hit will slow down your rate of movement
- You can fly through the enemy ships with your ship (no collision between enemy ships/hero ship)
- Some gamepad configurations may not work
- Menu navigation with gamepad is inconsistent
Copyright (C) 2017 ActiveState. Licensed under the MIT License. See LICENSE file for details.
Written by Pete Garcin Twitter/GitHub and Tom Radcliffe.
Gopher Artwork appears courtesy of Ashley McNamara.
If you would like to contribute to this project, please visit the Issues tab to see what open issues are available and flagged with Help Wanted. You can also submit a Pull Request with your proposed changes. If they are in response to an issue, please reference the issue in the pull request.