Sunday, May 06, 2007

The DarkNet FireFly Toy

Chapter 18 of The DarkNet is coming soon. In the meantime, I've built a toy to amuse readers who have a little time on their hands. (Click the image to the left if you want to download it.)

It's a widget toy I call FireFly. It's designed to demonstrate the emergence of complex behavior that sometimes results when groups of simple objects interact through a few basic rules. (You may not see the connection to the storyline in The DarkNet, but I hope you will soon.)

The toy consists of a 25 by 25 grid of artificial fireflies. A set of controls lets you adjust the average firefly flashing rate, the coupling that determines how the fireflies react to each other, and the amount of randomness in the toy that adds a touch of realism to the game.

I built this widget after reading about studies of fireflies that have been observed to synchronize their flashes. Heart cells synchronize in similar ways. Neurons in our nervous systems fire based on input from their neighbors, and epileptic attacks may arise when too many of them synchronize their firing.

If you want to try out the toy, but have never used a Yahoo Widget before, you'll first have to download and install the Yahoo Widgets 4 engine.

When you run FireFly, it loads with all the fireflies flashing at random times. Then you can start fiddling with the settings to search for interesting behavior. Here's a summary of the controls.

Note: I improved the controls a bit. The changes are incorporated into the following information

Flash Period - The up and down arrows increase or decrease the rate that the fireflies flash.

Coupling - Coupling is set to zero when the toy loads. That means the fireflies don't care what their neighbors are doing. Turning up the coupling causes each firefly to try to flash at the same time as its nearest neighbors. You can also decrease the coupling until it's negative - that means the fireflies will try to avoid flashing at the same time as their nearest neighbors.

Random Noise - In the real world, fireflies, heart cells and neurons don't flash at perfectly regular intervals. The random noise setting lets you turn up the reality by adding random jitter to the flashing rates of the fireflies.

Reset button - Sets all the fireflies to their live status with their flashing rate initially synchronized.

Random button - This button randomly sets the timing of all the live fireflies. A firefly is live if it's flashing. Between flashes, it is dull yellow. A dead firefly is grey and does not flash.

Synch button - Synchronizes all the live fireflies to the same timing. (if you have coupling or random noise set to non-zero values, the fireflies will probably desynchronize quickly)

Clear button - This lets you turn off all the fireflies (they all turn grey). Then you can click individual fireflies to turn them on. This way you can make patterns that sometimes do pretty unusual stuff. Clicking a flashing firefly shuts it off.

Play and Stop icons - These should be obvious.

Data Bar - The settings, along with a generations counter that shows how long the toy has been running in a given configuration, are displayed at the top of the widget.

That's all there is to it.

So far, I've found settings that create endlessly changing symmetrical designs, strings of fireflies that flash in patterns that seem to orbit around loops of various shapes, and signs of a sort of memory that scientists call hysteresis.

Drop me an email if you play with it and happen to find anything cool.

I adapted this widget from one built by Lawrence Levinson. He made the best version of John Conway's Game of Life that I've found in widget form. If you've never played with the Game of Life, you should check it out.

Thanks Lawrence, I hope you don't mind me riding on your coat tails.

By the same token, if you want to modify my widget to make it better or completely different, feel free. But be sure to send it to me so I can play with your widget too.


Youtube Videos Featuring Jonathan Coulton's Music