A Flash Developer Resource Site

Thread: Realistic 2D Single Ant Simulation in ActionScript?

1. Realistic 2D Single Ant Simulation in ActionScript?

I did a brief Google search on this, but didn't come up with anything immediately. Maybe I should try a few different search terms.

For a couple of minutes just now, I was watching a single ant move around the floor. It would scuttle about in what seemed a random way to me (though probably with lots of purpose to the ant) stop briefly at times (maybe to investigate stuff), and then go off on its way again.

Does anyone know of any realistic 2D single ant simulation(s) written in AS1/2/3? (Married ant simulations are OK also )

By realistic, I mean that if this code was executed for say one minute, when compared against a one minute video of a real ant moving about, most people would not be able to tell the difference. Kind of like the "Turing Test" (see Wikipedia for that), but using an animation of a single ant rather than computer-generated conversation.

If nothing exists in the AS1/AS2/AS3, maybe I should look to see if anything has been created in another language, and then convert it over, or at least look carefully at an ant's behaviours as a start to writing my own simulator.

If anybody has any advice, or links, they would be most appreciated!

2. Hey Simon,

I haven't seen any examples like this, but I have a pretty good idea how I'd implement.

I'd first generate a bitmap which corresponds to the surface the ant is travelling on. The bitmap isn't shown, but is used as a reference for the ant simulation.

The bitmap is mostly black, but also contains a few red wiggly lines on it, which correspond to folic acid trails left by other ants. There a few green spots, which correspond to crumbs.

When the ant is moving over a black area, he moves using brownian motion, which essentially propels him using small random numbers.

When the ant hits a trail, there is a probability that he will turn in the direction of the trail. The probability is weighted by the strength of the trail.

When the ant hits a crumb, he dwells there for a while, eating it, and then leaves when he is full.

Everywhere the ant goes, he leaves a faint trail. The red values of the pixels behind him are incremented by 1 value.

The trails slowly decay. This can be implemented by looping thru the pixels and darkening the red pixels a little bit, periodically.

In other words, I would basically use the bitmap to simulate the ant's environment, and implement the ant as a very simple stateless machine which is making decisions based on the presence of either crumbs, or folic acid.

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 » Home » Movies » Tutorials » Submissions » Board » Links » Reviews » Feedback » Gallery » Fonts » The Lounge » Sound Loops » Sound FX » About FK » Sitemap

Click Here to Expand Forum to Full Width