WA
wagenaartje/agario-ai
Neural agents learn to play in an agario-like environment with Neataptic
Agar.io-AI
This repository shows how you can use Neataptic to succesfully teach neural networks to play Agar.io. You can see the genomes live in action here. These genomes have been trained for over 1000 generations, and definetely show sume human-like traits. Visualisation done with P5.js.
Read an article on this repo here.
Settings
If you manage to optimize the settings, please perform either a pull request or create an issue here.
Settings (contained in js/main.js):
WIDTHset the width of the playing fieldHEIGHTset the height of the playing fieldMAX_AREAset the maximal area a genome can acquireMIN_AREAset the minimal area of a genomeRELATIVE_SIZEset how much migger a genome should be to eat a blobDECREASE_SIZEset how much area is kept each roundDETECTION_RADIUSset how far a genome can see (pixels)FOOD_DETECTIONset the maximal amount of food blobs a genome can detectPLAYER_DETECTIONset the maximal amount of other genomes a genome can detectMIN_SPEEDset the minimal multiplier speed a genome can have (bigger genomes move slower)MAX_SPEEDset the maximal multiplier speed a genome can have (smaller genomes move faster)FOOD_AREAset the area of food blobsFOOD_AMOUNTset the amount of food blobs on the fieldPLAYER_AMOUNTset the amount of genomes that play on the field (population size)ITERATIONSset the amount of iterations/frames each generation is tested forSTART_HIDDEN_SIZEset the amount of hidden nodes each genome starts witchMUTATION_RATEset the mutation rateELITISM_PERCENTset the percentage of elitism
Most important setting:
USE_TRAINED_POPsetting this tofalsewill start the evolution from scratch (USE THIS WHEN OPTIMIZING THE SETTINGS), setting this totruewill use the pre-trained population
Default setting values
var WIDTH = $('#field').width();
var HEIGHT = 800;
var MAX_AREA = 10000;
var MIN_AREA = 400;
var RELATIVE_SIZE = 1.1;
var DECREASE_SIZE = 0.998;
var DETECTION_RADIUS = 150;
var FOOD_DETECTION = 3;
var PLAYER_DETECTION = 3;
var MIN_SPEED = 0.6;
var SPEED = 3;
var FOOD_AREA = 80;
var FOOD_AMOUNT = Math.round(WIDTH * HEIGHT * 4e-4);
// GA settings
var PLAYER_AMOUNT = Math.round(WIDTH * HEIGHT * 8e-5);
var ITERATIONS = 1000;
var START_HIDDEN_SIZE = 0;
var MUTATION_RATE = 0.3;
var ELITISM_PERCENT = 0.1;
// Trained population
var USE_TRAINED_POP = true;On this page
Languages
JavaScript99.9%HTML0.1%
Contributors
MIT License
Created April 26, 2017
Updated April 14, 2025