Source code: evolvingAliens3
Built with Processing
This is a simple version of an arcade classic with a twist - the aliens get smarter by evolving.The aliens are controlled by artificial neural networks which guide their motion. The neural networks use the aliens' current position and speed, plus the position of the player's spaceship (for a total of 5 inputs) to determine each alien's next move. The neural network also has a hidden layer with 5 nodes and an output layer with two nodes - controlling the aliens next move in the x and y directions.
To adjust the aliens' behaviors the 'weights' between the nodes are changed. Each alien has a 'chromosome' that defines its weights and its color, shape, and size. More successful aliens, the ones that reach the bottom of the screen or hit the player's ship, get to reproduce into the next generation. Each alien gets tested three times (the three waves) to determine its 'fitness' for reproduction.
The numbers to the right of the screen (they show up once you start playing) show the average values of the neural network weights of the current generation of aliens. Note that initially two of the weights are relatively high (~15). This helps guide the aliens towards the player's spaceship. Starting with completely random weights makes the first dozen or so generations really boring.
For more details or questions please send me an email.