Virtual Formicidae Emporium

Virtual Formicidae Emporium,
a simulated formicarium

(or commonly called an ant farm, but the term ant farm is copyrighted by Uncle Milton Industries)

***UPDATE*** This applet no longers runs in a browser due to modern browser changes. However, I have made it a stand alone application. Download, unzip it into a directory, and double click on runAnts.jar. See readme.txt if you have any issues.


Running the Simulation

  • Left click on grass to feed them
  • Right click to summon an invader
  • Click and drag to generate a food trail.
  • Show Trails (turn off and on the 4 pheromone trails)
  • Loop Speed (fast moving or slow moving ants, does not effect hunger/age)
  • Random Feeding/Invaders (set to generate these automatically)
  • Auto Random (varies random Feeding/Invaders based on number of ants on the surface)
  • Stats on the colony do not include invaders
  • Some stats do not include the queen (example: ant ages)


    the hill I have always been fascinated by ants and how colonies work. Last year we gave one of my sons an ant farm and I enjoyed it as much as he did, watching them dig their tunnels. But, without a queen, the colony eventually dies. You can't buy a queen in the US (unlike Europe). We are going to try to catch one next summer. In the mean time I thought it would be fun to write a Java Applet simulating a colony -- my own virtual ant farm. I tried to make it realistic, but am aware no one wants to sit at their computer for a month while the colony gets moving. So, things like the life cycle are sped up, while things like looking for food are not. Here is how the virtual colony works:

    The Queen

    queen with and without wings In the beginning a queen ant appears and randomly tries to find a good place for a nest. She finds a spot and starts digging. Once deep enough she will eat her wings and lay her first eggs. The queen in my simulation will live for an hour. She has enough food to sustain her till her death. However, after her first 24 eggs, she won't lay any more unless fed. If fed, she will randomly look for a place to lay an egg, and if there is room next to her, she will. In the last minute of her life she will lay eggs that will eventually become nymphs. The nymphs are timed to all emerge from the pupa stage at once. When this happens, the nest is abandoned, all ants leave as the nymphs take flight. One will return and start a new nest and recruit those left behind from the old one.

    The Ant Life Cycle

    egg, larva, pupa, adult In my simulation, an ant's birth date is when it is laid as an egg. It just kept things simpler. An egg will hatch after 1 minute into a larva. Larva are quite hungry. While they don't need to be fed to live, they stand a much greater chance of making it and helping the colony if they emerge from the next stage with a full stomach. After 2 minutes, larva turn into pupa. Another 2 minutes, and they emerge as adults.

    The Adult Worker Ant

    adults at various ages Adults in the colony will live up to 30 minutes. However, they can only go 8 minutes between meals. Adults that emerge from the pupa stage without being fed as larva have 3 minutes to find their first meal. Any time an ant goes more than 4 minutes since the last meal, he finishes his current job and then starts looking for food, congregating near the top of the nest. If he gets to the point of only having 2 minutes to find a meal, the ant will leave the nest and become a gatherer. In this manner, hunger determines the ratio of gatherers to chamber maids. Ants emerge from the pupa stage in a bright red color. As they age you will see them turn to pink and finally to white before they die. Older ants that do not become gatherers will instead become guards and you will see them gather by the hole to guard it.

    Chamber Maids

    maid carrying dirt Every ant born by default is a chamber maid. Their job is to tend to the queen and the nest. The programming works like this. Ants will randomly wander up and down looking for something to do. If they come across the queen, they automatically feed her. They will also feed any hungry larva they come across. They do this through trophallaxis, a way ants share their body's food stores. Any time they get hungry and feed from the food stock, they automatically bring some back for the queen as well. Chamber maids are also in charge of keeping the nest organized. Anytime they come across an egg by the queen, they move it so she can lay more. Any larva by an egg they will move upwards, as well as any pupa by a larva. This puts them closer to the food. Whenever they move something, they will put it down the first valid place they find, and if they come up against dirt, they will dig it out. Dirt is moved out of the tunnel and you will be able to see the hill grow.


    gatherer carrying food Chamber maids become gathers anytime the nest is short on food. The first brood will always become gatherers. They search in a random pattern for food, but can only turn 90 degrees max each turn. This makes them search as opposed to just vibrating around in place. Once food is found, they feed themselves and then bring it back to the nest and place it just inside the hole. If they can't find a place to set the food, they increase the size of the chamber and dump the dirt on their way out.

    Pheromone Trails

    ants follow a food trail The simulated ants communicate the same as real ones, by putting chemical pheromones into the environment. I simulated 4 kinds: direction to the hole, direction to food, direction to the queen, and alert. Anytime an ant finds the hole, it starts leaving a trail back to it, above and below the surface. This allows any ants looking for the hole to quickly find it. Chamber maids use the same system to find the queen. Food trails do not last as long in the environment as the first two. Anytime food is found, a trail is left and gatherers on the surface use it to find additional food. Chamber maids will use the trail under ground to find the food store when hungry. The alert pheromone is used when there are invaders. This one is different in that it spreads out from the ant discovering the invader. Any ant who detects an alert will drop what they are doing, emit their own (not quite as strong) and then follow the trail to assist in taking out the intruder. In this manner, word is quickly spread to the surrounding area.


    bad ants An invasive blue ant species will sometimes enter the scene. Their goal is to wipe out the queen and destroy the nest. They will take any food they find and kill ants not yet adults. They are slightly stronger than our red ants, and it will take 2 or 3 of them to take them on. The intruders know our ant's pheromones and will look for the hole and then the queen through our own trails.