snakeneuralnetworkjs
DEMO: https://snakeneuralnetwork.herokuapp.com/
Neuroevolution of Neural Network of snakes in the Browser.
This is a demonstration of evolving a neural network thanks to genetics algorithms in the browser using a multilayer perceptron (150-15-15-1).
The initial population contains 36 individuals, each assigned a different genome. They will fight following a round-robin tournament. At the end the top 7 are kept alive, and the remaining 29 are created by breeding from the 7.
Each snake has 50 sensors, each reporting 3 inputs:
- The distance the sensor has hit something normalized between 0 and 1
- 1 if this sensor touched the enemy body
- 1 if this sensor touched the enemy body
Screenshot
Snakes fighting:
Sensors:
Green: The sensor touched the enemy body Yellow: The sensor did not report any activity Red: The sensor is hitting a wall or its own body Blue: The sensor is touching the enemy head
Install
- Note: requires a node version >= 6 and an npm version >= 3.
First, clone the repo via git:
git clone https://github.com/elyx0/snakeneuralnetworkjs.git your-project-name
And then install dependencies.
$ cd your-project-name && npm install
Run
$ node server.js
Then head to localhost:8080
in the browser.
Testing
$ npm run test