Experiment: Proximity Fireflies

Firefly communication through bioluminescence is a beautiful thing to watch, and I felt it could be easily modeled using my ProximityManager class, and a simple tolerance/potential system. I tried to make this system mimic the real interaction of Fireflies in nature, and was inspired by an article I found about an artist’s video of Fireflies in a Malaysian rain forest.


The Firefly sprites in this simulation fly around the screen, completely invisible in the dark. There are 350 Fireflies in the system, 90% male, 10% female. Female Fireflies blink at semi-random intervals – the light excites nearby males, who in turn may blink. This potentially triggers a cascade as males blink and excite other males (kind of kinky) who blink in turn, creating waves of light.

The more excited a Firefly is when it blinks, the brighter and whiter it glows (hence producing more light, and exciting other Fireflies more). This is achieved with simple scaling, alpha, and color transformations.

This experiment was very easy to code, but if took awhile to balance the tolerances and values to achieve the desired effect. I’m quite impressed that the Flash 7 player has enough power to track 350 sprites with this kind of behaviour as effectively as it does.

The logic is very similar to that used in my old crystallization experiment, but freed from the constraints of a rigid grid through the use of my ProximityManager class.

I’m going to be doing a show and tell about the code behind this experiment at the Edmonton Flash User Group meeting tomorrow, and might release the code on my blog in the next little while.

Here is all 2kb of it:

Grant Skinner

The "g" in gskinner. Also the "skinner".

@gskinner

3 Comments

  1. Once again…

    I bow before thee

  2. Nice piece of work!

    Let me invite you in my montreal MMUG when you want to talk about it 🙂

  3. Thanks for publishing the source code of the Proximity Mananager. I’ve been playing around all day with it, but can’t work out how you get the random nature of the fireflies to ‘light up’. I think I know how to ‘pass on the charge’ to it’s neighbours but I can’t seem to find a way to set the initial charge off? Any help or code possible?

    Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *