EvolvoBird is an interactive, browser-based simulator that teaches an artificial intelligence flock to play Flappy Bird using a Genetic Algorithm (GA) and a Feedforward Neural Network.
You can watch the birds evolve their neural connections in real-time, inspect their synapses, speed up or slow down time, adjust mutation rates, save/load models, or jump into the game yourself in manual play mode.
Since the application uses modern JavaScript ES6 Modules, it must be served via a local web server (loading directly from file:// will trigger browser CORS restrictions).
From the project folder, run:
npx http-server -p 8080Then open http://localhost:8080 in your browser.
From the project folder, run:
python -m http.server 8080Then open http://localhost:8080 in your browser.
The simulator combines a neural network (representing the bird's brain) and a genetic algorithm (simulating evolution).
Each bird has its own small feedforward neural network structure: 4 inputs -> 5 hidden neurons -> 1 output.
-
Inputs:
-
DX(Distance X): Horizontal distance to the next obstacle. -
DYT(Distance Y Top): Vertical distance to the bottom edge of the upper pipe. -
DYB(Distance Y Bottom): Vertical distance to the top edge of the lower pipe. -
VY(Velocity Y): The bird's current vertical speed.
-
- Hidden Layer: 5 neurons mapping non-linear relationships.
-
Output: A single neuron yielding a float between
0.0and1.0. If output$> 0.5$ , the bird flaps its wings.
Evolution optimizes neural connection weights and biases over successive generations:
- Fitness Evaluation: A bird's fitness score increases with its survival time. Passing a pipe awards a large fitness bonus (+1200 points).
- Elitism: The single best-performing bird (the "Elite") is copied directly into the next generation without modification, ensuring the AI never regresses.
- Roulette-Wheel Selection: Parent birds are selected probabilistically. Birds with higher fitness have a higher chance of passing their genes down.
- Crossover: Offspring inherit weights and biases randomly mixed from two selected parent birds.
- Mutation: Small random offsets (Gaussian noise) are added to the weights and biases of children to discover new strategies.
- index.html: UI structure, sliders, buttons, canvas elements, and data display cards.
- style.css: Glassmorphic dashboard styles, neon grid background effects, and custom sliders.
- nn.js: Forward propagation logic, mutations, and uniform crossovers.
- ga.js: Breeding, fitness aggregation, and roulette-selection handlers.
- game.js: Physics updating, parallax starry skyline, collision handlers, and flock renderers.
- app.js: Coordination script connecting UI actions, storage interfaces, chart renders, and the active animation loops.
- Speed Multipliers: Speed up physics updates (
2x,5x,10x,20x, orMAX) to accelerate training speeds. - Manual Mode: Take control of a custom red bird by pressing
Spacebaror clicking the canvas to challenge the AI. - Live Neural Network Diagram: Highlights active neurons and shows positive (cyan) and negative (red) weights of the leading bird.
- Fitness Graph: Plots the highest and average fitness scores over time to visualize training trends.
- Save/Load Brain: Export the current leading brain to LocalStorage so you can restore training progress later.