C#
Unity
Neural Network
Duration: October - November 2017 (2 weeks)
Implemented an Artificial Neural Network (ANN) to learn and play a rendition of the popular Flappy Bird game. Clearly defined the inputs (horizontal and vertical distances to closest column) and fitness values (distance traveled and time alive), while processing the output (value between 0 and 1) appropriately. The diagram below shows the ANN, with 2 inputs, 4 hidden neurons (1 hidden layer), and 1 output. After experimenting with different values for the number of inputs, hidden layers, and outputs the previously mentioned settings proved to be the "sweet spot". Utilized Unity's RayCasts and Overlap functions to determine input values of the ANN. Goal of this project was to make the neural network as smart as possible while attempting to learn the game.
Implemented a genetic algorithm to filter out neural networks that were efficient at learning. Each run of the game is its own neural network (i.e. genome). After twelve runs of the game, I had to create a new genetically augmented population of neural networks to run that was influenced by the previous generations. Using the fitness score as a measure, I devised a way to create the next generation from the top 4 genomes: kept the best of the old generation; crossbred and then mutated old genomes to make new ones; and randomly created new genomes to get out of a possibly bad gene pool. The genetic algorithm continues to create new generations until the perfect "child" is created to eventually master the game.
If you're interested in seeing any sample code or executable files, please contact me