Play classic Nokia snake game by reinforcement learning with Keras. This project is a great starting point to learn how reinforcement learning works and implementation of deep learning with Keras. Keras is a high level Python deep learning library based on Theano or TensorFlow. We use Q-learning to teach snake how to move. This Q-learning tutorial is an awesome material to get the idea how it works.
git clone [email protected]:wing3s/snake_game.git
cd snake_game
# Install app required packages
pip install -r requirements.txt
If you have any issue with matplotlib package installation, please follow below steps.
# Install a Python version
PYTHON_CONFIGURE_OPTS="--enable-unicode=ucs2 --enable-framework CC=clang" pyenv install <your_python_version>
pyenv virtualenv <your_python_version> <your_virtualenv_name>
# Install app required packages
git clone [email protected]:wing3s/snake_game.git
cd snake_game
# Install app required packages
pyenv activate <your_virtualenv_name>
pip install -r requirements.txt
# add missing file for matplotlib in Python virtualenv
echo "backend: TkAgg" >> ~/.matplotlib/matplotlibrc
# Install freestyle, png packages
sudo apt-get install freetype* libpng*
# Install a Python version
PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install <your_python_version>
pyenv virtualenv <your_python_version> <your_virtualenv_name>
# Install app required packages
git clone [email protected]:wing3s/snake_game.git
cd snake_game
# Install app required packages
pyenv activate <your_virtualenv_name>
pip install -r requirements.txt
python terminal.py
Simply move the snake by arrow keys ←, → ↑ ↓.
- 1: snake or wall
- F: target fruit
python run_bot.py
Trained model is saved to /models
with its json structure and weights by default.
This project is inspired by following resources.