Inspiration
Over the summer, I built a simple Flappy Bird program. Since I'm really interested in ML, I decided it would be a great foundation for a first project!
What it does
Using an artificial neural network along with a genetic algorithm, the program learns how to beat the game by itself.
How I built it
The first task was to create a basic matrix library with various functions needed for the neural network to feedforward. Then came constructing the network; manipulating the inputs (the bird's distance to various obstacles) with weights, biases, and activation functions to generate an output (whether the bird should jump at that moment). Finally, I created a genetic algorithm used to optimize the neural network. I run the game with 1,000 birds at once, each with its own random neural network. Then, I take the neural network of the bird that performed the best and make 1,000 copies of it in the second generation, except each one has been slightly mutated to produce slightly different results. I repeat this process until I have an optimal neural network that beats the game!
Challenges I ran into
The last 24 hours weren't easy! By far the most difficult task was constructing the neural network using the functions from my matrix library. Having to take the inputs of each layer, multiply them by the weights, add the biases, and pass them through an activation function was quite difficult to implement in code. The second challenging task was figuring out how to mutate each neural network; choosing how to manipulate the weights and biases of the best network in each generation just enough so that at least some of the birds in the following generation perform better.
Accomplishments that I'm proud of
It's crazy to watch the computer get better at the game, by itself, in real-time! It just comes to show the power of Artificial Intelligence and the potential it has to revolutionize everything.
What's next for Flappy Bird AI
It was not easy building a neural net from scratch! A follow-up project would be to write the same program using TensorFlow, a deep learning library that makes it much easier to build neural networks. I could then use my knowledge of TensorFlow to develop almost any deep learning program, from classifying images to making a chatbot to generating new music!

Log in or sign up for Devpost to join the conversation.