You are going to create a simulated ant colony, in which the user will take the role of the queen who's duty it will be to manage the health of the colony. The simulation will proceed in a turn-based fashion, where each turn the user can choose to spend precious food resources on more ants.
Begin by creating two classes: Colony and Ant.
The Colony class will maintain an array of worker ants (initially empty with room for 100 ants), an amount of food (initially 10), and 3 methods: breedWorker(), step(), and purge().
breedWorker() creates a new Ant and adds it to the colony's list of worker ants. Creating a worker costs 5 of the colony's food. If there is insufficient food, a message should be printed to the user and no ant should be created.
step() proceeds the simulation by one turn, and handles the automatic behaviour of the colony. Namely, this method will control the behaviour of each ant in the colony. Each turn each ant should eat one food from the colony's food supply. If there is not enough food, the ant will lose one point of health instead. All dead ants should then be purged from the colony. Lastly, each ant will then forage for food (described below), and any food found will be added back into the colony's food supply.
Note: All ants should eat before any ants are purged.
purge() scans the list of worker ants, and any ants with 0 health are removed from the list. For each dead ant add 1 to the food supply, because ants recycle! Also, notify the user that an ant has died. (Note, see tutorial 4 for an idea of how to do this).
The Ant class will have a health (initially set to 10), and a forage() method.
forage() determines randomly the luck an ant has while out searching for food each turn.
There is a 10% chance that the ant dies in a horrible accident (health = 0, return no food)
There is a 35% chance that the ant finds food. The amount found should be a random number between 1 and 5.
There is a 50% chance that the ant finds no food.
And there is a 5% chance that the and finds sweet nectar! Her health is replenished (i.e., set to 10) and she brings back 10 food to the colony!
The results of each ant's foraging should be both printed for the user and returned to update the colony's supply.
Finally, you will need to write a main() method to start the simulation and repeatedly prompt the user for their choices. This can be placed in the Colony class or in its own class. Each turn the user should be prompted with the current state of the colony (number of ants, and food supply). A menu should be displayed with two options: to breed a new worker (for a cost of 5 food), or do nothing (no new ants for a cost of 0 food). Your code should check the user's input for errors and ask again if it was invalid. Following the user's action (breed or not), the colony will take one simulation step as described above. Simulation should repeat like this until the colony is out of both ants and enough food to make more ants.