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

  Analog measurements prepare an assembly program for the

analog measurements prepare an assembly program for the correctly measures the wind direction to a precision of 45deg n

  Arm assembly language program

Arm Assembly language Program: The safe starts unlocked, cannot be locked and there are no valid codes. Whenever there are no codes the safe cannot be locked

  Provide the rtl instructions

Provide the RTL instructions and the time steps that will facilitate the execution of the following assembly language instructions  LDA addr,x  STX addr,x

  Design and develop an embedded system

Assembly language program to control the operation of the embedded system and thorough testing to ensure correct operation of system

  Write a program in assembly language

Write a program in assembly language which uses BIOS interrupt INT 21 to read current system time and displays it on the top-left corner of the screen.

  Assembly language program that generates and displays

Write a assembly language program that generates and displays 20 random strings, each consisting of ten letter(A-Z, a-z)s or number(0-9)s.

  Write an arm assembly function that takes an array of intege

Write an ARM assembly function that takes an array of integers and returns the index of the first occurrence of the integer in the array if it exists or -1 if it does not. Remember the initial integer in the array is at index zero.

  Write a function to convert a given function

Write a function to convert a given function from infix to postfix in assembly. The basic structure of the function is given in the attached assembly language file.

  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

  Prompts for an int8 value to inspect and then prints

Write an HLA Assembly program that prompts for an int8 value to inspect and then prints it in binary format.

  Document the protocols for passing

You must document the protocols for passing parameters and returning the result to the subroutine and also follow the convertion of saving and restoring registers in the subroutine.

  Write a function in linux assembly

Write a function in Linux assembly

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