This project is an AI-driven version of the popular Flappy Bird game. It uses a neural network and genetic algorithm to train birds to navigate through pipes. The game showcases how machine learning can be applied to simple games to achieve superhuman performance.
flappy_bird.mov
- Flappy Bird game mechanics
- Neural Network implementation for bird control
- Genetic Algorithm for evolving better birds over generations
- Visual representation of the best-performing bird
- Adjustable game speed
- Display of current generation, alive birds, current score, and all-time high score
- HTML5
- CSS3
- JavaScript
- p5.js (for game rendering and animation)
- A population of birds is initialized with random neural network weights.
- Each bird uses its neural network to decide when to flap based on inputs like distance to pipes and vertical position.
- Birds that hit pipes or go out of bounds are removed from the game.
- The fitness of each bird is calculated based on how far it travels.
- The best-performing birds are selected to "breed" and create the next generation.
- Mutations are applied to add variety to the gene pool.
- This process repeats, with each generation generally performing better than the last.
- Open
index.html
in a web browser. - Watch as the AI birds attempt to navigate through the pipes.
- Use the speed slider to adjust the game speed.
- Click the "Run Best" button to see the best-performing bird in action.
index.html
: Main HTML filestyles.css
: CSS stylingsketch.js
: Main game logic and p5.js setupbird.js
: Bird class definitionpipe.js
: Pipe class definitionneuralnetwork.js
: Neural network implementationalg.js
: Genetic algorithm functions
- Add more complex obstacles
- Implement different types of neural networks
- Allow users to train their own birds
- Add sound effects and background music
This project is open source and available under the MIT License.