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

  Create a assembly language subroutine

Create a assembly language subroutine MULSUM that takes an array named A containing n bytes of positive numbers, and fills two arrays, array B containing n words and array C containing n long words

  Write a function in linux assembly

Write a function in Linux assembly

  Analog measurements

Prepare an assembly program for the correctly measures the wind direction

  Design a simple digital clock

Design a simple digital clock

  Write an assembly program

Prepare an Assembly program that reads in a number of cents.

  Write an assembly language program

Write an assembly language program for encrypting alphabates of a string

  Greatest common divisor of integers-masm assembly language

Must be done in MASM assembly language: Greatest common divisor of two integers is largest integer which will evenly divide both integers. GCD algorithm involves integer division in a loop.

  Write assembly program-find right admission price to movie

Write the Assembly program to find correct admission price to movie. Price of admission to a movie is $7 for kids (under 12) and $9 for adults.

  Create simple 8-bit alu using add-subtract-shift functions

Create a simple 8-bit ALU. Requirements:The eight functions that you will implement are: add, subtract, and, or, shift left logical, less than, shift right logical.

  Write assembly program print binary representation-integers

Write the assembly program called hw6_ex1, stored in file hw6_ex1.asm. This program must prompt user to enter signed 32-bit integer. Program must print out binary representation of the integer.

  Allot op-codes and add microcode to microprogram

Allot op-codes and add microcode to microprogram of Mic-1 to implement following instructions which are then included with IJVM instruction set.

  Write mips assembly program to read two non-negative numbers

Write MIPS assembly program to repeatedly read two non-negative integers and print integer product and quotient without using multiplication and division instructions.

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