Skip to main content

FireFly simulator

I've been on a widget building kick lately. My most recent widget is a toy that lets you adjust the way a grid of simulated fireflies interact with each other. (You can download the toy by clicking on the image to the right. But you'll need to get the Yahoo Widgets 4 engine first if you've never used a widget before.)

I've built various versions of this thing over the years, starting with programs I wrote in BASIC on the Apple II PCs in my high school programming class, to hardware fireflies made of LEDs and TTL chips in my college lab (I was supposed to be doing experiments for my electricity and magnetism lab, but I got distracted), to Pascal, Fortran and Visual C++ programs - and finally a widget.

These days, things like this are described as examples of the emergence of complexity in systems of simple objects. I didn't know that when I made my first one, but I was intrigued to find the pretty patterns that formed all by themselves when I gave the simulated fireflies a few rules to help them decide when to flash.

In this widget, fireflies live on a 25 by 25 grid. They each have an internal timer that tells them how long to wait between flashes.

Interesting things can happen when you instruct them to pay attention to their nearest neighbors and change the timing of their next flash based on what's going on nearby.

To make a firefly want to flash at the same time as those around it, you turn up the coupling between fireflies. If you want them to avoid flashing along with their neighbors, you can turn the coupling down until it's negative.

You can also add some randomness to the timing (with the 'random noise' setting), or change the period that fireflies wait between flashing with the 'flash period' controls.

There are a few other controls to fiddle with. The rest of the instructions are on my other blog, The Dark Net.

I built the widget version of this toy in part for my own amusement, and in part as a present for all the people who have signed up to read my online science fiction novel. I'm also hoping it will keep them from getting bored waiting for the next chapter to come along.

Have fun.



Popular Posts

How 4,000 Physicists Gave a Vegas Casino its Worst Week Ever

What happens when several thousand distinguished physicists, researchers, and students descend on the nation’s gambling capital for a conference? The answer is "a bad week for the casino"—but you'd never guess why.

Ask a Physicist: Phone Flash Sharpie Shock!

Lexie and Xavier, from Orlando, FL want to know:
"What's going on in this video? Our science teacher claims that the pain comes from a small electrical shock, but we believe that this is due to the absorption of light. Please help us resolve this dispute!"

The Science of Ice Cream: Part One

Even though it's been a warm couple of months already, it's officially summer. A delicious, science-filled way to beat the heat? Making homemade ice cream.

(We've since updated this article to include the science behind vegan ice cream. To learn more about ice cream science, check out The Science of Ice Cream, Redux)

Over at Physics@Home there's an easy recipe for homemade ice cream. But what kind of milk should you use to make ice cream? And do you really need to chill the ice cream base before making it? Why do ice cream recipes always call for salt on ice?