Ant Colony Simulation 100 points
For the semester project you will be designing a simulation of an ant colony. Ant colonies are interesting for a variety of reasons, but one of the most interesting features of an ant colony is that it demonstrates a property known as emergence. Ant colonies are composed of thousands of individuals that carry out their assigned tasks. The combined individual behaviors of all the ants bring about the emergence of a self- organized system: the colony itself. Each ant only lives for about one year, except for the queen, which can live for 20 years or more. The colony can survive as long as the queen still lives, meaning the colony can also survive for 20 years or more. Since the individual ants only live for about a year, the colony isn't able to benefit from the wisdom of old "wise" ants. The colony lives simply because each individual ant does what it has been programmed to do. A well-ordered ant society emerges from the synergistic actions of the individuals.
The colony you create will consist of a queen and her brood, which will have workers to gather food and scout the terrain surrounding the colony, and soldiers to protect the colony from enemies. The colony will start off with only the queen and a few workers and soldiers. Over time the colony will expand to function like a real ant colony, to a limited extent. Since you will be building a simulation, how your colony behaves will depend on how certain parameters have been set. The purpose of a simulation is to mimic reality as closely as possible, but in many cases there may not be enough facts on hand to build an accurate simulation. In such cases, it is beneficial to build the simulation in a way that allows the various parameters to be changed easily. I will be providing you with values for as many parameters as I can, but many aspects of the simulation involve the use of random numbers. Therefore, the precise end result is indeterminate. When I grade your project I won't be looking for a single, correct end result; instead I will be looking to see that the various components (i.e., the various ants) do their jobs correctly. If you are able to program your ants to do what they are supposed to do as individuals, your colony should emerge from their collective efforts
A. The Environment
The ants' environment should be represented using a 27 x 27 square
Each square in the grid represents a discrete location in the
Eight directions of movement are possible (see diagram below).
The entrance to the colony is represented by a single square located in the center of the grid. The queen is located in this
The remaining squares will initially be unexplored
Certain ants (scout ants) will be capable of revealing the areas that have not been
All other types of ants will only be allowed to move into squares that have been revealed by scout
Each square can contain one or more of the following, in any combination:
Zero or more enemy ants
Zero or more friendly ants
Zero or more units of food
Zero or more units of pheromone
B. Ant Types
There are five types of ants in the simulation:
Each ant type is described in more detail below.
C. Characteristics Common to All Ant Types
Each ant should be identified by a unique integer ID. The queen ant should have an ID value of Other ants should be numbered in ascending order as they are hatched.
All ant types (except for the queen) have a maximum life span of 1
Dead ants should be removed from the
All ants are limited to one action per turn, with some exceptions that will be discussed later.
All ants except Bala ants may only move in squares that have been revealed by scout ants; Bala ants may also move into squares that have not been revealed by scout
When moving, all ant types should move no more than 1 square per
D. The Queen Ant
The queen ant is responsible for hatching new ants. The specific requirements for the queen ant are:
The queen never moves from her square (i.e., she remains in the same square for the entire simulation).
The queen's maximum lifespan is 20
The queen hatches new ants at a constant rate of 1 ant/day (i.e., 1 ant every 10 turns).
New ants should always be hatched on the first turn of each
The type of ant that is hatched should be determined randomly according to the initial frequencies listed below. You may change these frequencies as you see fit — these are simply suggestions for a starting
Forager - 50%
Scout - 25%
Soldier - 25%
The queen should consume 1 unit of the food in her chamber on each turn, including the turn in which she hatches a new ant. If the food level in the queen's square is zero when the queen tries to eat, the queen dies of starvation.
If the queen dies, either by starvation or by a Bala attack, the simulation should end immediately.
Foragers are responsible for bringing food to the queen. They have two primary modes of behavior: forage mode and return-to-nest mode. The specific requirements for the forager ant are:
Foragers are considered to be in forage mode whenever they are not carrying
In Forage Mode, foragers should always move to the adjacent square containing the highest level of pheromone, except:
If more than one adjacent square has the same level of pheromone they should randomly pick one of those squares.
When following a pheromone trail a forager should never move into the square it just came from unless it has no other
Depending on how you implement your movement algorithm, it is possible for a forager to get stuck in a loop, traveling round and round the same squares without getting anywhere. Try to detect when this happens, and prevent the endless
Foragers should maintain a history of their movement, to be used when they need to return to the
When a forager enters a square containing food, it should pick up 1 unit of food, unless it is already carrying
When a forager picks up a unit of food, it enters return-to-nest mode.
Foragers should never pick up food from the square containing the
After a forager has picked up 1 unit of food, it should not move again until the next
When a forager is carrying food, it should retrace its steps exactly back to the colony entrance; i.e., it should backtrack whatever path it took to get to the
Foragers should ignore pheromone in this mode; i.e., they should not move to the adjacent square containing the highest level of
Foragers should not move randomly in this
Foragers should deposit 10 units of pheromone in each square along the way back to the colony entrance,
including the square in which the food was found, but excluding the colony entrance (the queen's square).
Foragers should only deposit pheromone in a given square if the current pheromone total in the square is <
A forager may deposit pheromone in one square, and move to a new square in the same
When a forager reaches the colony entrance, it should add the food it is carrying to the food supply in that square, in the same turn in which it entered the colony
Foragers should not move out of the colony entrance on the same turn they deliver food
If a forager dies while carrying food, the food it was carrying should remain in the square in which the forager died.
When a forager has deposited food at the nest, the forager re-enters forage mode, and its movement history should be
Scouts are responsible for enlarging the foraging area available to the foragers. The specific requirements for the scout ant are
Scouts should always randomly pick one of the eight possible directions of movement when it is their turn to do
If the chosen square is open, the scout should simply move into that
If the chosen square is closed, the scout should move into that square and the contents of that square should be revealed.
Whenever a closed square is revealed, there is a chance of there being food in the square, according to the following frequency:
There is a 25% chance that the square will contain a random amount of food between 500 and 1000
The other 75% of the time the square is
You can predetermine the contents of all the squares at the beginning of the simulation, or you can dynamically determine the contents of each square as it is
G. Soldier Ants
Soldiers are responsible for protecting the colony by fighting the enemy Bala ants. Soldier ants have two primary modes of behavior: scout mode and attack mode. The specific requirements for the soldier ant are:
A soldier is in scout mode when it is in a square that does not contain any Bala ants.
While in scout mode:
If there are one or more Bala ants in one or more of the squares adjacent to the square the soldier is in, the soldier should move into any one of the squares containing a Bala
If there are no Bala ants in any of the adjacent squares, the soldier should move
A soldier is in attack mode when it is in a square that contains one or more Bala ants. Attack mode takes precedence over scout
While in attack mode, a soldier should attack any Bala ants
If there are multiple Bala ants present, only one of them should be
During an attack, there is a 50% chance the soldier kills the enemy ant; otherwise, the soldier misses and the enemy
H. Bala ants
Bala ants are enemies of the colony. They should enter only at the periphery of the colony (i.e., they should not simply pop up in the middle of the colony). Once in the colony they may move around freely. Assume they never leave the colony once they enter it. The specific requirements for the Bala ant are:
Each turn there is a 3% chance one Bala ant will appear in one of the squares at the boundary of the colony. You may choose to have Bala ants always enter at the same square (e.g., upper left corner), or you may have them enter randomly at any of the 106 squares on the edge of the
Once a Bala appears, it should remain in the environment until it is killed, or dies of old
Bala ants should always move
Bala ants may move into squares that have not yet been revealed by scout
If a Bala ant is in a square containing one or more friendly ants (scout, forager, soldier, queen), the Bala should attack one of those ants. The ant that is attacked can be selected at random, or you can pick which ant gets
During an attack, there is a 50% chance a Bala kills the ant it attacks; otherwise, the Bala misses and the ant that is attacked survives.
I. Passage of Time in the Simulation
Time plays an important role in controlling what happens in the simulation. Each "day" in the simulation is divided into 10 "turns". Certain things happen at regular time intervals in the simulation:
The queen produces a new ant on the first turn of every
The pheromone level in each square should decrease by half (rounded down) each day (10 turns), but should never go below zero.
Every turn, each ant in the simulation should get a chance to perform an action, as defined above, depending on the ant
Ants may die in one of several ways:
They may be killed by an
They may die of old age (they will die the day after they have reached their maximum allotted lifespan).
Starvation (only applies to the queen).
DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma
Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t
Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of
1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of