flappy bird ai
Game speed | |
Mutation rate (%) | |
Generation | |
Highscore | |
Error rate | |
Nearly perfect since gen |
about the project
This project was my first ai project. It taught me how AI works and how to use it to make applications smarter.
At this time, I didn't have much experience with coding games, so forgive the code mess and the lack of a custom coordinate system.
how it works
In every generation, there is an x amount of players. Each player is equipped with a brain. It also keeps the state if the player is dead or not.
The brain, or neural network, gets 5 inputs:
- y location of the player
- y bottom location of the top pipe
- y top location of the bottom pipe
- x location of the closest pipe
- the current y velocity, ignoring the gravity
When all players of a generation are dead, the best is taken by its travel distance.
Then, the next generation gets filled with copies of the best one of the last generation.
Last step, every one except one gets mutated by 5%. This ensures the last best one still exists in the new generation.
This procedure has some problems, but it works for that situation.