Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Question: The goal for this programming project is to create a simple 2D predator-prey simulation. In this simulation, the prey is ants, and the predators are doodlebugs. These critters live in a world composed of a 20 20 grid of cells. Only one critter may occupy a cell at a time.

The grid is enclosed, so a critter is not allowed to move off the edges of the grid. Time is simulated in time steps. Each critter performs some action every time step. The ants behave according to the following model:

• Move. Every time step, randomly try to move up, down, left, or right. If the cell in the selected direction is occupied or would move the ant off the grid, then the ant stays in the current cell.

• Breed. If an ant survives for three time steps, then at the end of the third time step (i.e., after moving),the ant will breed. This is simulated by creating a new ant in an adjacent (up, down, left, or right) cell that is empty. If there is no empty cell available, no breeding occurs. Once an offspring is produced, the ant cannot produce an offspring until three more time steps have elapsed.

The doodlebugs behave according to the following model:

• Move. Every time step, if there is an adjacent cell (up, down, left, or right) occupied by an ant, then the doodlebug will move to that cell and eat the ant. Otherwise, the doodlebug moves according to the same rules as the ant. Note that a doodlebug cannot eat other doodlebugs.

• Breed. If a doodlebug survives for eight time steps, then at the end of the time step, it will spawn off a new doodlebug in the same manner as the ant.

• Starve. If a doodlebug has not eaten an ant within the last three time steps, then at the end of the third time step, it will starve and die.

The doodlebug should then be removed from the grid of cells.
During one turn, all the doodlebugs should move before the ants.

Write a program to implement this simulation and draw the world using ASCII characters of "o" for an ant and "X" for a doodlebug.

Create a class named Organism that encapsulates basic data common to both ants and doodlebugs. This class should have an overridden method named move that is defined in the derived classes of Ant and Doodle bug. You may need additional data structures to keep track of which critters have moved.

Initialize the world with 5 doodlebugs and 100 ants. After each time step, prompt the user to press Enter to move to the next time step. You should see a cyclical pattern between the population of predators and prey, although random perturbations may lead to the elimination of one or both species.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92417858
  • Price:- $10

Priced at Now at $10, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Question 1you want a list of products whose product lines

Question 1 You want a list of products whose product lines contain the term  Classic  or  Vintage.  please pick up best option from the following. a. SELECT productline FROM products WHERE MATCH(productline) AGAINST('Cla ...

Question suppose that in n a particular implementation of

Question : Suppose that in n a particular implementation of the MIPS single-cycle design, the lw instruction takes the longest amount of physical time to execute at 3.5 ns. What would be the theoretical maximum clock rat ...

In python why would one use a decision statement contained

In Python, Why would one use a decision statement contained inside the branch of another decision statement?

We talked a few times about slow migration from ipv4 to

We talked a few times about slow migration from IPv4 to IPv6 in the U.S. What was the primary motivating factor to migrate to IPv6? What are two other advantages of IPv6 over IPv4? Why is China farther along in implement ...

Analyze the time complexity of the following ternary search

Analyze the time complexity of the following ternary search algorithm: identify two points that subdivide a sorted array into three parts. If the given number is equal to one of these two points, we are done. Otherwise, ...

If we compare and contrast the four market structures it is

If we compare and contrast the four market structures, it is evident that one market structure is most practiced and evident in the United States. It is the one that promotes and strives on competition. It is the one tha ...

Question suppose that we run a greedy search algorithm with

Question : Suppose that we run a greedy search algorithm with h(n) = -g(n). What sort of search will the greedy search emulate? What if h(n) = g(n)? What sort of search does greedy search emulate in this case? Explain yo ...

Select three interfaces and consider how the teamwork

select three interfaces, and consider how the teamwork application could be redesigned for each of these types. Use your imagination. How about using a tangible interface or even a drone to help remote students collabora ...

Taskwrite a cc program to emulate a simple calculator that

Task Write a C/C++ program to emulate a simple calculator that can calculate and display the results of performing one of the following arithmetic operations between two integer numbers (+, -, *, /). The Calculator progr ...

Eleven people have eleven different favorite numbers from 2

Eleven people have eleven different favorite numbers from 2 to 12. They all agree to participate in a 10,000-roll dice game where they bet $1 on their favorite number for each roll of two standard (fair) dice. A donor ki ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As