Something Wrong with the System

A Flash/Actionscript blog

The Swarm

Recently I watched a video on In the video Steven Strogatz talks about sync, in one segment he speaks about flocking behavior and lists the three simple rules that govern flocking.  Later I found that this type of artificial flocking behaviour can be referred to as ‘Boids‘.

So yeah… I decided to code it up in Flash ActionScript 3.0.

The image on the left doesn’t really do the app justice.
Click more to see the app in action.

If you're curious about the various particle states:

Blue = A lonely particle.  It's trying to meet its neighbour.

Green = A happy particle. It will head towards the mouse cursor.

Red = A particle that is too close to its neighbour and is in the act of moving away.

Source code is available here in AS3

January 7th, 2009 by Peter Organa

6 Responses to “The Swarm”

  1. dominic Says:

    this is pretty cool.
    thanks for posting the source, I’ve been trying to understang boids and flocking for a little while now.

    nice job.

  2. mindfocker Says:

    cool.. i want to play with this. thanks for the source.

  3. Craig Reynolds Says:

    Hi. Nice job, thanks for providing the source. I cited it here:

    and that thread will “eventually” get folded in with the OpenSteer doc.

  4. Santanu Says:

    Pretty cool. And thanks for posting the source.

  5. Martin Skovgaard Says:

    The angle of the boids are messed up when you leave the browser for a long time.

    (not that it matters though).

  6. Peter Says:


    Weird Martin.
    Thanks for the heads up 😀