-
Install nodejs,
-
npm install
-
then node server.js
-
You can now view the simulation at: localhost:3000/index.html
-
or you can view automated training at localhost:3000/
-
average convergence: 74 generations! :-)
This repository shows how you can use Neataptic to succesfully teach neural networks to trace targets. You can see the genomes live in action here. These genomes have been trained for over 100 generations and are very effective. Visualisation done with P5.js. The next step would be adding collisions, to possibly reveal some interesting tactics.
Read an article on this repo here.
If you manage to optimize the settings, please perform either a pull request or create an issue here.
WIDTH
set the width of the playing fieldHEIGHT
set the height of the playing fieldMAX_SPEED
set the maximal multiplier speed a genome can have (smaller genomes move faster)START_X
set the x-location from which each genome (and the target) startsSTART_Y
set the y-location from which each genome (and the target) startsSCORE_RADIUS
set the distance to the target from where genomes get assigned scorePLAYER_AMOUNT
set the amount of genomes that play on the field (population size)ITERATIONS
set the amount of iterations/frames each generation is tested forSTART_HIDDEN_SIZE
set the amount of hidden nodes each genome starts witchMUTATION_RATE
set the mutation rateELITISM
set the amount of elitism
Most important setting:
USE_TRAINED_POP
setting this tofalse
will start the evolution from scratch (USE THIS WHEN OPTIMIZING THE SETTINGS), setting this totrue
will use the pre-trained population
var WIDTH = $('#field').width();
var HEIGHT = 800;
var MAX_SPEED = 5;
var START_X = WIDTH/2;
var START_Y = HEIGHT/2;
var SCORE_RADIUS = 100;
// GA settings
var PLAYER_AMOUNT = Math.round(2.3e-4 * WIDTH * HEIGHT);
var ITERATIONS = 250;
var MUTATION_RATE = 0.3;
var ELITISM = Math.round(0.1 * PLAYER_AMOUNT);
// Trained population
var USE_TRAINED_POP = true;