- This is a Neuroevolution simulation that combines both Neural Networks and Genetic Algorithms to play the game Flappy Bird.
- It takes about 20 generations for the boid to become good at the game, and about 50 to master it.
- The simulation speed and birds per generation can be adjusted using the sliders at the bottom left of the page.
- Well performing boids can be saved and loaded into the game.
Link: Boid
-
Boid class:
- Gravity
- Y-velocity
- Jump on Key Pressed
- Die on collision
- Boid image
- Change head pointing position while flying
-
Pipe class:
- Two Rectangles
- X-velocity
- Spacing
- Pipe Image
-
Create Environment:
- Create World
- Create Boid
- Create Pipes
- Handle collisions
- Background Image
- Make a Scoreboard
- Track generations
- Design NN Architecture (10/10/2 vs 6/10/2)
- Create Layers
- Randomize weights
- Add activation functions
- Copy Neural Network function
- Predict / Think function
- Save NN of boid with Best Fitness in JSON format
- Load NN from JSON and assign it to a boid
- Create a Generation of Boids
- Implement Mutate function
- Implement a Crossover function
- Copy NN with best fitness
- Create a generation of mutated boids from best NN
- Create a slider for learning speed
- Store boids with best Fitness from every generation
NOTE: It is recommended to have at least 100 boids per generation for a faster training.