Virtual Formicidae Emporium, a simulated formicarium
(or commonly called an ant farm, but the term 'ant farm' is copyrighted by Uncle Milton Industries)
Written in HTML5/Javascript. If you are looking for the old Java version similar to this, go here.
Running the Simulation, Settings Explained
Random Feedings: Ranging from none to bountiful, use this to feed your ants while you are away.
Random Attackers: Ranging from none to at war, use this to test the colony.
Game Loop Speed: Ranging from slow to fast, use this to change the pace. Note that this changes the time frame. On the slow setting 1 minute is stretched to 10 minutes. On fast that minute is compressed to 6 seconds. Note that as the colony grows large, it may slow the sim down.
Click Action: You can do the following with a click of the mouse (or a tap to the screen):
- feed - feed your ants
- poison - if you must
- invader - launch an invader
- add ant - add an ant
- squish - watch your step!
- dig - help them out
- info - pick an ant to track
- zoom - get a closer look
Show Trails: You can choose to display the 4 trails ants are using. Note that having these on may slow the program.
START: Officially starts the simulation, can only be pressed once
FULL SCREEN: Put the simulation in full screen mode. Hit Escape to leave, or back on your phone. Note that actions in this mode may or may not work correctly.
Information is displayed with stats on the colony. Most of these will be reset on change of the queen. Information on tracked ants is displayed below that.
Background
I have always been fascinated with ants.
What they can do relative to their individual size is amazing.
My kids had Ant Farms and they were great fun to watch.
However, without a queen, the colony will eventually die out.
In the U.S. you are not allowed to purchase queens like in Europe and other places.
So, years ago I built a Java Applet version (link above).
Most browsers no longer support Applets, so I decided to rewrite the simulation in HTML5/Javascript.
If you view the page source you can see my code.
There are no coding libraries, just vanilla JS.
Be nice if you critique it, I programmed it without any design phase, and it needs optimizing.
Read below to see how the colony works.
The Queen
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 and burrowing.
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 9 eggs, she won't lay any more unless fed.
When laying an egg, she looks for a place to lay it, and if there is room behind 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 the same time.
When this happens, all maid ants become gatherers and leave as the nymphs take flight.
One nymph will return and start a new nest and the gatherers left will support the new nest.
The Ant Life Cycle
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.
Larvae 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, a larva will turn into a pupa.
Another 2 minutes, and they emerge as adults, unless they are too low in the nest.
If pupae are left too deep, they will not emerge and may ultimately die.
The Adult Worker Ant
Adults in the colony will live up to 30 minutes.
However, they can only go 8 minutes between meals, shorter if they have been feeding other ants.
Adults emerge from the pupa stage as chamber maids.
If they weren't fed as larvae they have 3 minutes to find their first meal.
Any time a maid goes more than 4 minutes since the last meal, they finish their current job and then start looking for food, congregating near the top of the nest.
If they get 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
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 wander around looking for something to do.
If they come across any hungry adults (including the queen) or larvae, they will feed them.
They do this through trophallaxis, a way ants share their body's food stores.
If they get hungry they'll head for the food store at the top of the nest.
Any time they eat, they will bring some to 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 larvae below the queen they will move upwards, as well as any pupae below larvae.
This puts pupae closer to the food for their first meal.
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.
Gatherers
Chamber maids become gathers anytime the nest is short on food.
The first brood will always become gatherers.
If the first 6 ants out of nest do not find food, the colony is doomed.
They search in a random pattern for food, but can only turn 30 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
The simulated ants communicate the same as real ones, by putting chemical pheromones into the environment.
They are essentially blind and rely heavily on the trails they create.
I simulated 4 kinds: direction to the hole, direction to food, direction to the queen, and alert.
Anytime an ant passes in or out of 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 as they will leave trails after feeding her.
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.
In the absence of any pheromones to guide them, the ants will randomly look for whatever it is they are seeking.
The alert pheromone is used when there are invaders.
This one is different in that it spreads out from the ant discovering the invader and then also emits from the invader itself (not visually indicated in the sim).
Any ants within range will then charge to that location or any invader they become aware of.
Invasive Ant Species
An invasive blue ant species lives in the same environment as our colony.
Their goal is to wipe out the queen and destroy the nest.
They will fight any ants they come across and outright kill any immature ants.
They are slightly stronger than our red ants, and it will take several of them to take them out.
The intruders know our ant's pheromones and will look for the hole and then the queen through the colony's own trails.
Poison
If you want to see how poison effects the colony, you can try it out.
Poisoned ants become green.
Basically once poisoned, any other ant that gets fed by the poisoned ant becomes poisoned as well.
If the queen becomes poisoned, her brood after that is poisoned.
A poisoned ant is unable to restore their energy stores.
They will still eat and go about their duties, but their stomachs will not fill.
Eventually the colony will die off.
|