Interactive demo

Neuro-Drones: Watch Neural Networks Learn to Fly and Fight

In plain English

Sixty small drones each get a tiny artificial brain with random wiring. At first they wobble and crash. After every attempt the best pilots are copied with small random changes, and the worst are dropped. Nobody programs how to fly: within a few minutes of watching, smooth flight lines emerge on their own. In a second mode, a red team and a blue team learn to fight each other with lasers the same way.

Everything runs live in your browser, on your phone or computer, and keeps learning for as long as the page is open.

Race mode after 28 generations: the chase camera follows the leading drone through a ring
Race mode after 28 generations. The white ring marks the current leader, whose brain is drawn live in the panel on the right.

What you are watching

Neuro-Drones is a demonstration of neuroevolution: training neural networks by selection and mutation instead of by gradients. It is meant to make learning visible. Every drone is flown by its own network, every decision it makes is drawn in real time, and the learning curve updates after each generation, so you can watch a population go from random behavior to competent flight without anything being scripted.

There are two modes. Race is a single population learning to fly a course of rings. Battle is two populations, red and blue, learning to fight each other, which turns learning into an arms race. Switch between them with the buttons in the top-left panel.

Race mode: learning to fly

Sixty quadcopters launch from a pad toward a course of 24 rings. Each drone flies a simplified quadcopter model, the way a hobby drone does in "angle mode": thrust along its tilted body, gravity, drag, and an altitude assist that makes zero throttle a hover.

  • The brain is a small network: 18 inputs, two hidden layers of 14 and 10 neurons, and 4 outputs (throttle, tilt forward, tilt sideways, turn). That is 460 numbers in total, and those 460 numbers are the drone's entire skill.
  • What it senses, all measured from its own point of view: the direction and distance of the next ring and the one after it, its own speed, altitude and tilt, and five range sensors that report how close the nearest obstacle is ahead, left, right, low ahead and straight down.
  • How it is scored: 100 points per ring, partial credit for progress toward the next one, a bonus for speed, and a penalty for crashing.

When every drone has crashed, finished or run out of time, the generation ends and the next one is bred:

  • The best 6 brains are copied unchanged, so a good solution is never lost.
  • Parents are picked by small tournaments: 7 drones at random, the best one wins.
  • A child inherits each neuron whole from one parent or the other, then about 3% of its numbers are nudged at random. Those nudges are where new skills come from.
  • Two brand-new random brains join each generation to keep the population varied, and the size of the nudges adapts: smaller when the swarm keeps setting records, larger when it is stuck.

Every 6 generations the course is redrawn, so the swarm has to learn how to fly rather than memorize one route. Once any drone passes 12 rings, the swarm levels up: sharper turns and more pillars, then wind gusts from level 3 and pillars that slide across the course from level 4. This is a curriculum, the same idea as teaching easy material first.

Race mode at level 5: wind streaks and moving pillars
Level 5: streaks show the wind, and orange-capped pillars slide across the course.

Battle mode: learning to fight

Twenty red and twenty blue drones start on opposite sides of a round arena with mirrored cover pillars, so neither side has an advantage. They fly with the same physics as race mode and also carry a laser: the brain aims it up or down and decides when to fire, and to aim left or right a drone has to turn its whole body. Each drone can take 3 hits. Pillars block shots, and a force-field wall and ceiling push drones back into the arena. A round ends when one team is wiped out or after 45 seconds.

Each team evolves separately. Red only breeds from red, and blue only from blue. Each team's world is the other team, so when one side finds a better trick, the other side's scores drop until it finds an answer. This is called co-evolution, and it is why the score between the two teams can swing back and forth for a long time without either side getting worse.

A fighter is rewarded for hits (+10), kills (+20) and being on the winning team (+15), with small rewards for staying alive and for keeping its laser lined up on an enemy, and penalties for crashing, for pressing against the force field and, very slightly, for missing.

Battle mode: red and blue drones fire lasers; hits flash white with an expanding ring
Laser hits flash white with an expanding ring in the shooter's color. The dots above each drone are its remaining health.

A hall of fame keeps the arms race honest. Co-evolution has a well-known failure: two teams can chase each other in circles, each forgetting how to beat strategies it already beat once. So every few rounds each team archives its champion, and every fourth round is a rematch: one team fights a squad of the other side's past champions, shown with gold health dots. Only the live team learns from a rematch, so it is pushed to keep beating its own history, and the share of rematches it wins is a progress measure that the score between the two teams cannot give.

A rematch round: blue fights a squad of red's past champions, marked with gold health dots
A rematch: blue against twenty of red's past champions. The gold markers on the battle chart show earlier rematches.

The senses

A battle drone's inputs are built from a small library of senses. Each sense is a separate module that declares the inputs it provides and how to compute them, and the brain's input layer is sized from whichever senses are switched on. That makes it straightforward to add a new kind of sense later, or to compare two sets of senses against each other.

SenseInputsWhat it gives the drone
Nearest enemy4Exact direction and distance of the closest enemy, even behind cover.
Nearest teammate4Exact direction and distance of the closest teammate.
Own motion6Speed in each direction, altitude and tilt.
Combat status3Own health, whether the laser has recharged, and whether an enemy laser is pointed at it.
Obstacle rays5Distance to pillars, the ground and the wall in five directions.
Tactics9How many enemies and teammates are within laser range, which side has more drones left, the nearest enemy's health and whether it is reloading, whether there is a clear shot, and the direction of the best target: the weakest enemy in range with a clear shot.
Hearing7Two ears and a sense for sounds behind. Every drone hums, louder at full throttle, and every laser shot is a loud bang. Sound fades with distance but goes around pillars and comes from every direction, so it is blurry but can find enemies the drone cannot see. Enemy and teammate engines sound different, so they are heard separately.
Light4Three forward-facing eyes see the glow of enemy drones, and a fourth channel catches muzzle flashes. Light fades with distance and is blocked by cover, so hiding works against it, but it points more sharply than hearing.

With every sense switched on, a battle brain has 42 inputs, hidden layers of 16 and 12 neurons, and 6 outputs: 970 numbers. The first five senses are the original set; tactics, hearing and light were added in version 0.8. When senses are added, brains that were already trained carry over: the new inputs start with zero weight, so the drones behave exactly as before until evolution finds a use for them.

With the sensor display switched on, the drone being followed shows what it perceives: gold lines for what its eyes see and purple lines for what its ears hear, each growing with the strength of the signal.

What we measured

All of these come from headless runs of the same simulation, with the commands recorded in the project so they can be repeated.

  • Race, learning speed. Averaged over 10 independent runs of 48 generations, the best drone passed 11.6 rings per course over the last 12 generations, up from 6.6 before the curriculum and selection were tuned. Repeat runs differ by roughly one ring.
  • Race, long runs. In 150-generation runs, 6 of 6 kept leveling up, reaching levels 11 to 20 with best flights of 9 to 18 rings.
  • Battle, does it learn? The score between two co-evolving teams cannot show progress on its own, because both sides improve together. So trained teams were frozen and pitted against brand-new random teams, a different opponent and arena every round. After 60 rounds of training, trained teams won 296 of 300 of these rounds across 5 runs; random against random comes out about even.
  • Battle, does the hall of fame help? Yes, modestly and consistently. Teams trained with rematches against past champions were pitted against teams trained without them, from both sides in fresh arenas: over 14 runs of 80 rounds the hall-of-fame teams won 321 of 560 rounds (57%) and came out ahead in 10 of the 14 runs. It is the first change to battle mode that beat the previous version head to head, so it is on by default.
  • Battle, do the new senses help? Not yet, and the reason is now clear. Teams with all eight senses were trained alongside teams with only the original five, then fought each other from both sides in fresh arenas: over 10 runs the teams with the new senses won 163 of 400 rounds (41%), and with bigger teams of 40 a side 55 of 120 (46%). Giving already-trained teams the new senses and comparing them with the same teams carrying on without came out exactly even, 200 of 400: free, but no gain yet. The reason is that the original nearest-enemy sense is x-ray vision: it gives the exact direction of the nearest enemy straight through cover, so hearing and light mostly repeat what a drone already knows. Take x-ray vision away and drones still learn to fight with only hearing, light and line of sight (they beat brand-new random teams 394 times in 400), but they lose to x-ray-sighted teams about two rounds in three.

How to use it

  • Click or tap any drone to follow it: the camera, the brain view and the family tree switch to that drone. Esc goes back to the leader.
  • Speed: 1x, 3x, 10x and 40x. At 40x a generation takes seconds.
  • Cameras: chase, cinematic, overview, top-down and free. C cycles them, V jumps to top-down, the mouse wheel or a two-finger pinch zooms, and dragging switches to the free camera.
  • Smooth on any device: the graphics adjust themselves, lowering resolution and glow effects if your device struggles and raising them again when it can keep up.
  • On a phone the panels fold away so the drones have the screen. The ⓘ button shows what is going on, and the three buttons in the control bar open the brain, the learning chart and the debug panel.
  • Keyboard: Space pause, 1 to 4 speed, T trails, S senses, H shadows, B and F brain or family tab, D debug panel, N new course or end the round, M sound.
  • Experiment with the senses: in battle mode the senses menu switches each sense on or off. Try Realistic, which takes away x-ray sight of the nearest enemy, and watch your trained teams adapt. Experiments start from your saved teams and never overwrite them.
  • Progress is saved in your browser after every generation, so closing the tab does not lose what the swarm has learned. Reset starts over. On a computer the save menu also downloads the swarm (race) or both teams (battle) as a file you can load again later or share.
The family tab: a drone with its parents and grandparents
The family tab: who a drone's parents and grandparents were, and how they scored.

How it is built

The neural network, the evolution and the flight physics are written from scratch in plain JavaScript, with no machine-learning library: every brain is one flat array of numbers, which is what lets evolution treat it as something to copy and mutate. The 3D view uses three.js. The simulation runs at a fixed 60 steps per second regardless of the frame rate, and the faster speeds run more steps per frame. Nothing is sent to a server; the only thing stored is the autosave in your own browser.

The project is tested the way production software is: unit tests for the network, the evolution, the physics and every sense, browser tests that drive the real page (including the phone layout), and fixed-seed fingerprints that prove a change to one mode leaves the other mode's simulation bit for bit unchanged.

The debug panel open beside the swarm
The debug panel shows every technical number: the evolution settings, fitness statistics, and the followed drone's live inputs and outputs.

Limits

  • These brains are tiny and have no memory: each step they decide only from what they sense at that moment. They cannot plan, and in battle they cannot coordinate beyond what the tactics sense tells them.
  • Neuroevolution is a good way to make learning visible, but it is not how large modern AI models are trained; those use gradient descent on far bigger networks. The principle on display, improvement by measured selection rather than by hand-written rules, is the part that carries over.
  • Battle results are noisy. Each run of co-evolution settles on its own strategies, so two runs with identical settings can produce teams of very different strength. That is why the measurements above use many runs and fresh opponents.

Want this measured on your data?

We build private models our clients own and run on their own infrastructure, and every engagement proves measured lift on the client's own tasks before we call it done. Start free with a readiness scorecard that tells you whether your data can support it, or book a short call.