Flappy-Bird-Genetic-Algorithms
Flappy-Bird-Genetic-Algorithms copied to clipboard
Use genetic algorithms to train flappy bird
Flappy Bird Genetic Evolution
Train a neural network using genetic evolution to play flappy bird! For a tutorial on how to get started with your own genetic algorithms, take a look here.
Final Results
Algorithm Details
- Starts out with a pool of 50 models
- Each iteration based on fitness scores of the models, perform crossover
- Crossover would swap the first layers (input -> hidden) for both the selected parents
- Random mutation ensures that the models are changed at every iteration
Progress Screenshots
Stage 1
Initially all the models would do the "same" wrong thing. So they would all die out quickly.
Stage 2
After some time however, they would start to show more variation, but still perform the wrong moves. This gives us a spread of flappy birds throughout the screen (lengthwise).
Stage 3
After a bit of training (~1hr) the spread decreases and is more concentrated at the height where there is a hole in the pipes. They start performing a lot better since they now understand when to flap and when not to.
Stage 4
The model with the maximum fitness can be considered as a trained model and it would perform much better than the average human.
Disclaimer
- Based on Flappy Bird clone in pygame, https://github.com/sourabhv/FlapPyBird