Create a simulated ant colony

Assignment Help Assembly Language
Reference no: EM13811447

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.

Reference no: EM13811447

Questions Cloud

Create an event planning document : Create an event planning document in which you input the information pertaining to your application including the following: The object, The event trigger and The event process
Define taxation to create dependent interest groups : The State uses the fruits of conquest and taxation to create dependent interest groups who will justify its existence.
Explain the core principles or features of the theory : Explain the core principles or features of the theory and the general account of moral behavior it provides and a brief description of the primary reason(s) supporting your position.
Individual management planning presentation : Individual Management Planning Presentation
Create a simulated ant colony : 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..
Create database using professional principles and standards : Your database project must meet the following assessment requirements - Create a database using professional principles and standards.
Applicable sociological concepts : Applicable Sociological Concepts
Entire transformational change management plan : You will create an entire Transformational Change Management Plan for a medium-sized public company that has lost business to a competitor that has chosen to outsource much of its production operations.
Explain what are the goals of alternative sanctions : What are the goals of alternative sanctions. What recommendations do you have regarding victims' rights

Reviews

Write a Review

Assembly Language Questions & Answers

  Program that prints your full name on the screen

write an assembly language program that prints your full name on the screen

  Multiply by using shift and add instructions

How does real time PCR work to quantify the initial amount of the DNA template? How should the method be modified to quantify the initial amount of RNA template extracted from tissue or cells?

  Program that converts the temperature

Write a program that converts the temperature F in Farenheit to C in Celsius using C = (F-32)*5/9. For ease of programming you can display the result in fractions

  Write an arm assembly function that takes an array

Write an ARM assembly function that takes an array of integers and insures that all entries are positive. Remember the initial integer in the array is at index zero.

  Cache statistics for two versions of matrix multiplication

Explore the cache statistics for two versions of matrix multiplication - Cache can be configured using the preference in ARMSim. For getting cache statistics, first put a breakpoint on SWI 0x11 instruction, and then note the statistics from cache

  Prepare a assembly program to initialize the led outputs

Write a main.asm file in PSoC designer. Make sure to have the subsequent in place - Initialize the LED outputs to 0's and Set the corresponding bit in INT_MSK0 to 1.

  Write an assembly program that reads in a number of cents

Write an Assembly program that reads in a number of cents. The program will write out the number of dollars and cents separately

  Integral square root of an input number

Write a short assembly program that computes the integral square root of an input number and In this problem you will write a program that will compute the first 20 numbers in the Fibonacci sequence.

  How the expression is written in postfix notation

Describe the Floating Point Unit data stack and describe how the expression is written in postfix notation

  Assignment related to arm assembly

The 8-Segment display and LEDs will show status of the safe: U: indicates safe is unlocked, L: indicates safe is locked, P: indicates safe is programming a code, C: indicates safe is confirming a new code

  Write a program sequence that places the value in address

write a program sequence that places the value in address 1000 into accumulator a and places the value in address 1001

  Part a clockuse a timer interrupt to design a simple

part a clockuse a timer interrupt to design a simple digital clock. this clock will count only minutes and seconds

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd