Skip to content

Genetic algorithm · 2021

Genetic Flappy Bird

A Flappy Bird clone in Python, where a population of small neural networks learns to play through selection and mutation.

The project

I rebuilt Flappy Bird with pygame: bird, pipes, collisions and score.

Each bird is driven by a neural network with 3 inputs, 5 hidden neurons and 1 output. The inputs are the vertical speed, the horizontal distance to the next pipe and the vertical distance to the centre of the gap.

At each generation, the 1000 birds play at the same time and the best half is kept. Children are made by averaging the weights of two parents and adding a little noise. Training runs for 100 generations.

Next project
Sand Box