jnathnjshua / snake

Neural Network trained by genetic algorithm playing snake game

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Snake

Neural Networks playing snake game trained by genetic algorithm

A personal project made by Robin Mancini and myself, consisting in training neural networks to play the game "Snake"

This repository contains:

  • The Snake Game itself
  • A Genetic Algorithm module
  • A Neural Network module
  • A main file with toy examples

I timed most functions to be sure to improve speed and used numba jit for compiling some functions, the genetic algorithm is parallelized for its main part (snakes evaluation) using multiprocessing and joblib

Installation

Python 3 was used for this project and I can't promess that older versions are compatibles

Libraries you'll need to run the project:

{joblib, numpy, numba, pygame}

Clone the repo using

git clone https://github.com/valentinmace/snake.git

Usage

You will find some ready to run examples in main.py file.

You can try to:

  • Play snake
  • Train your own neural networks (it can take a while to get good results)
  • Display a game played by neural networks that I trained and selected four you

Everything is explaind in the file, just uncomment parts that you want to execute, then go to terminal and do:

python main.py

Notes

Do not hesitate to contact me if you need some help

Everything is made by me, I did not want to use existing framework for the genetic algorithm or neural network for learning purposes. I also coded the game with performance in mind rather than conception elegance.

I have published (or will publish depending on when you read this) a serie of youtube tutorial videos on my channel (in french)

Meta

Valentin Macé – LinkedInYouTubeTwitter - valentin.mace@kedgebs.com

Distributed under the MIT license. See LICENSE for more information.

About

Neural Network trained by genetic algorithm playing snake game

License:MIT License


Languages

Language:Python 100.0%