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.
1. The ants' environment should be represented using a 27 x 27 square grid.
2. Each square in the grid represents a discrete location in the environment.
3. Eight directions of movement are possible (see diagram below).
There are five types of ants in the simulation:
1. Queen
2. Forager
3. Scout
4. Soldier
5. Bala
Each ant type is described in more detail below.
1. Each ant should be identified by a unique integer ID. The queen ant should have an ID value of 0. Other ants should be numbered in ascending order as they are hatched.
2. All ant types (except for the queen) have a maximum life span of 1 year.
3. Dead ants should be removed from the simulation.
4. All ants are limited to one action per turn, with some exceptions that will be discussed later.
The queen ant is responsible for hatching new ants. The specific requirements for the queen ant are:
1. The queen never moves from her square (i.e., she remains in the same square for the entire simulation).
2. The queen's maximum lifespan is 20 years.
3. The queen hatches new ants at a constant rate of 1 ant/day (i.e., 1 ant every 10 turns).
4. New ants should always be hatched on the first turn of each day.
5. 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 point.
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:
a. Foragers are considered to be in forage mode whenever they are not carrying food.
b. In Forage Mode, foragers should always move to the adjacent square containing the highest level of pheromone, except:
i. If more than one adjacent square has the same level of pheromone they should randomly pick one of those squares.
ii. When following a pheromone trail a forager should never move into the square it just came from unless it has no other choice.
iii. 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 looping.
c. Foragers should maintain a history of their movement, to be used when they need to return to the nest.
d. When a forager enters a square containing food, it should pick up 1 unit of food, unless it is already carrying food.
2. Return-to-nest Mode
a. 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 food.
b. Foragers should ignore pheromone in this mode; i.e., they should not move to the adjacent square containing the highest level of pheromone.
c. Foragers should not move randomly in this mode.
d. 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).
Scouts are responsible for enlarging the foraging area available to the foragers. The specific requirements for the scout ant are:
1. Scouts should always randomly pick one of the eight possible directions of movement when it is their turn to do something.
a. If the chosen square is open, the scout should simply move into that square.
b. If the chosen square is closed, the scout should move into that square and the contents of that square should be revealed.
2. Whenever a closed square is revealed, there is a chance of there being food in the square, according to the following frequency:
a. There is a 25% chance that the square will contain a random amount of food between 500 and 1000 units.
b. The other 75% of the time the square is empty.
c. 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 opened.
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:
1. Scout Mode
1. A soldier is in scout mode when it is in a square that does not contain any Bala ants.
2. While in scout mode:
1. 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 ant.
2. If there are no Bala ants in any of the adjacent squares, the soldier should move randomly.
2. Attack Mode
1. 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 mode.
2. While in attack mode, a soldier should attack any Bala ants present.
3. If there are multiple Bala ants present, only one of them should be attacked.
4. During an attack, there is a 50% chance the soldier kills the enemy ant; otherwise, the soldier misses and the enemy ant survives.
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:
1. 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 colony.
2. Once a Bala appears, it should remain in the environment until it is killed, or dies of old age.
3. Bala ants should always move randomly.
4. Bala ants may move into squares that have not yet been revealed by scout ants.
5. 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 attacked.
6. 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.
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:
1. The queen produces a new ant on the first turn of every day.
2. The pheromone level in each square should decrease by half (rounded down) each day (10 turns), but should never go below zero.
3. Every turn, each ant in the simulation should get a chance to perform an action, as defined above, depending on the ant type.
Ants may die in one of several ways:
1. They may be killed by an attack.
2. They may die of old age (they will die the day after they have reached their maximum allotted lifespan).
3. Starvation (only applies to the queen).
1. The dead ant should be removed (i.e., deleted) from the square it is in.
2. If the ant died before it had a chance to do something, it does not get to do anything posthumously on that turn.
Your simulation should begin with the center square of the environment and its adjacent squares open (see figure below).
The center square represents the entrance to the colony. It should contain the following:
1. the queen ant
2. 10 soldier ants
3. 50 forager ants
4. 4 scout ants
5. 1000 units of food
The simulation should end immediately after the queen dies, either from starvation, from old age, or from an attack.
Since this is a fairly complex project, it is useful to have two different modes of execution:
1. Continuous Execution
In this mode the simulation simply runs non-stop until the ending state is reached.
2. Stepwise Execution
In this mode the simulation can be stepped forward one turn at a time, either at the click of a button or by a key press. This is helpful for observing what happens from one turn to the next. This mode is extremely valuable for testing purposes.
You must use a graphical user interface (GUI) for this project. A GUI will allow you to more easily interpret what is happening in the simulation as you test and debug your project. You have two options:
1. You can use the GUI I have provided. The challenge here is that you will need to design your simulation to use it. The GUI has all the necessary methods for your simulation to update it. You will need to understand how those methods work in order to connect your simulation to the interface.
2. You may build your own GUI.
Below is a screenshot from the prototype project I've built, which uses the GUI I have provided. The squares containing text have been revealed by scout ants. The gray square near the center is the colony entrance, and contains the queen ant (the gold-colored ant in the upper right corner of the square). Scout ants are blue, soldier ants are black, and forager ants are green. The violet squares represent the pheromone trail that has been laid down by the foragers that found a food supply in square 9,5. The color changes to the various colors of the spectrum to reflect the strength of the pheromone concentration (violet = lowest, red = highest).
If you decide to use the GUI I have provided, you only need to make sure the following buttons are implemented:
1. Normal Setup - Clicking this button should initialize the simulation (see "Initial State of the Simulation", above). This button should be clicked prior to clicking either the Run or Step buttons.
2. Run - After the simulation has been set up, clicking this button will run the simulation continuously.
3. Step - After the simulation has been set up, clicking this button will run the simulation one turn at a time.
The buttons labeled <Ant Type> Test are there for your own convenience for testing purposes. You are not required to implement these buttons. You can use these buttons to set up the simulation with special starting conditions that will help you test the operation of each ant type individually, which is very useful.
CS 340 Milestone One Guidelines and Rubric Overview: For this assignment, you will implement the fundamental operations of create, read, update,
Retail Transaction Programming Project Project Requirements: Develop a program to emulate a purchase transaction at a retail store. This
7COM1028 Secure Systems Programming Referral Coursework: Secure
Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip
CS 340 Final Project Guidelines and Rubric Overview The final project will encompass developing a web service using a software stack and impleme