This weekend we set out to learn more about how Neural Networks work and what they can be used for. We created our our own NN from scratch instead of opting to use Keras to better be able to understand the inner workings of a NN.
What it does
The final result is a genetic algorithm which uses the process of natural selection, mutation, and cross breeding to create a flappy bird Neural Network which trains to play the game.
How I built it
Rather that use stochastic gradient descent we used a genetic algorithm to train our neural network. We created a Network class which implements a mating and mutation function which return new neural networks. By taking the top performers of each epoch and generating the rest through mutation and cross-breeding, eventually through the process of natural selection we are able to generate an AI which jumps at the right time.
Challenges I ran into
Our first exercise was to use the Neural Net for simpler objectives other than playing flappy bird. We were successfully able to train the Neural Net to perform the XOR and AND operations, however when we tried to implement addition and 4 bit integer addition we were unable to get a successful result even when the error was low. We believe this was a result of overtraining on the input data.
The next challenge was reimplementing a python version of flappy bird to support multiple birds at once, in addition to taking output from the neural net to decide whether to jump or not instead of keyboard input.
Accomplishments that I'm proud of
The best flappy bird was able to reach a score of 350 by the 30th generation.
What I learned
I learned more about neural networks in addition to techniques such as genetic algorithms and stochastic gradient descent.
What's next for Flappy AI
Our next goal is to implement a genetic algorithm to build bridges for load testing. One of the challenges we expect is coming up with a good measure of fitness when the bridge breaks.