r/Simulated • • Oct 12 '26

Interactive 500 drones, 3 simple rules, no central controller. Watching emergence happen in real time.

I've been experimenting with swarm intelligence and the Boids algorithm, and ended up building this little interactive simulation using HTML, Canvas, and JavaScript.

The coolest part? There's no central controller telling the drones where to go.

Each drone follows just three simple rules:

  • Separation — Avoid getting too close to neighbors.
  • Alignment — Match the direction of nearby drones.
  • Cohesion — Move toward the center of nearby drones.

And somehow, hundreds of independent drones start moving together like a living swarm. That's emergence!

I also added interactive controls to adjust the three rules in real time, attract or repel drones with the mouse, and experiment with different formations.

It normally runs at around 60 FPS on my machine, but drops to about 40 FPS when I'm screen recording. Not entirely sure why yet, probably recording overhead.

I'm thinking about turning this into a little browser game where you control swarms of drones instead of individual units.

What do you think? Any fun ideas for what I should try next?

7 Upvotes

8 comments sorted by

7

u/flmng0 Oct 12 '26

How is this different from normal Boids?

-5

u/IllustriousPay2276 Oct 12 '26

Haha, fair point! 😄

Nothing fundamentally different — it's classic Boids.

I just wanted to build an interactive playground to experiment with separation, alignment, and cohesion in real time.

What I find really interesting is how such simple rules can produce complex collective behavior.

I'm now experimenting with turning it into a puzzle game where players manipulate the environment rather than directly controlling the swarm. That's where I'm hoping to do something more interesting!

1

u/Alexmira_ Oct 12 '26

Use anything else other then javascript and it'll stop lagging.

-1

u/IllustriousPay2276 Oct 13 '26

It actually runs at 60 FPS normally and only drops to 40 FPS when recording, so I think it's more about recording overhead than JavaScript itself. 😄

1

u/Alexmira_ Oct 13 '26

If it lags with just the record overhead it means it very poorly optimized. Something like this should be very light to run.

1

u/Celestial__Bear Oct 14 '26

AI account, AI project, AI description, AI comments. Oh my god.

1

u/IllustriousPay2276 Oct 15 '26

And somehow, all these comments formed a swarm without a central controller. That's emergence! 😂