Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

This lab continues the processing for a game of Life that was started in the Life Matrix assignment. We have a matrix of organisms in a rectangular area, represented by a matrix of booleans. The organisms reproduce and die out according to rules based on population density. At each time advance some new organisms may be born and existing ones may die. Existing organisms may die due to overcrowding or isolation. New ones are born when nearby cells reflect an appropriate population density.

The game is thus parameterized by the particular population density ranges that allow organisms to be born or to continue to thrive. Each cell has up to eight neighbors (above, below, left, right, and four diagonals). Thus, if you count the cell as well, there are nine cells in its neighborhood. For a birth to occur, the cell must be empty and the neighborhood density be in the birth range. The birth range can be given as two integers from zero to nine, birthLow and birthHigh, so that a birth will occur if the cell is empty and the neighborhood population is at least birthLow and no more than birthHigh. Similarly, a death occurs in a cell if there is an organism there and the neighborhood has less than the minimum population for survival, or greater than the maximum. Hence there is a live range provided as two integers from zero to nine, liveLow and liveHigh. The border of the area is not compatible with life, so the top and bottom rows and the left and right columns will never have organisms. This part of the assignment will take the matrix built in the previous assignment and make discrete time increments to advance the state of the game.

Specifications

Your program will read the parameters from standard input. Do NOT include any prompts - prompts will cause the program to fail when tested against my output! This second phase begins as the Life Matrix program began by reading the number of rows, the number of columns, and a seed to randomly fill the matrix. The number of rows and columns are integers, the seed is a long. The new inputs for this part are the values for the ranges, birthLow, birthHigh, liveLow, and liveHigh. You must read the values in exactly that order with no other input. After building the matrix as in the previous assignment, you should print the matrix, as in the previous assignment, and then repeat for five iterations of updating the matrix and printing the result. To calculate whether an entity lives at a given cell for the next iteration, you will need to calculate the number of entities in the neighborhood and compare the count with the birth range (if the cell is empty) or live range (if there was already an entity there). Note that the count must be based on the values as of the previous iteration. This means that you will need to make a copy of the matrix before doing the updates so you can count entities in neighborhoods based on original values. You should run five update and print cycles.

Instructions

You should use several public static methods with appropriate parameters in this assignment. Choose methods that are clean and do not mix functionality. That is, you should not print from inside a method that will update the state, nor should you change the state in a print method. You should not use any non-local (class or instance) variables. To count entities in the neighborhood, you will need to make a copy (clone) of the matrix. This is tricky because asking the matrix for its clone, with myMatrix.clone(), will result in a matrix with the same rows so that updates to the original rows will change the rows in the clones! What you need to do is create a new matrix by cloning the original and then cloning the rows of the original as in:

boolean[][] myNewMatrix = (boolean[][])myMatrix.clone();

for (int row=0; row < myMatrix.length; row++) {

myNewMatrix[row] = (boolean[])myMatrix[row].clone();

}

Remember that the borders of the area are toxic so entities cannot be born along the border. So in doing the update, start at row 1, column 1 and stop one less than the last row and column of the matrix.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91625228
  • Price:- $35

Priced at Now at $35, Verified Solution

Have any Question?


Related Questions in Computer Engineering

A substring is a contiguous sequence of characters from a

A substring is a contiguous sequence of characters from a string. For example, "cde" is a substring of the string "abcdefg". We say that substring s1 is duplicated in string s if s1 shows us in s at least two times, with ...

What are the characteristics of perfect competition and

What are the characteristics of perfect competition, and does is exist in the real world?

Margaret moore wants to invest in four-year bonds that are

Margaret Moore wants to invest in four-year bonds that are currently priced at $863.49. These bonds have a coupon rate of 5.1 percent and make semiannual coupon payments. What is the current market yield on this bond? (R ...

Why is formative evaluation importantprovide at least three

Why is formative evaluation important? Provide at least three reasons for using it. What is the difference between formative and summative evaluation? Provide any two types formative evaluation and two types of summative ...

Question what is the relation between virtual memory a

Question : What is the relation between virtual memory, a memory map, physical memory and swapping to secondary memory? The response must be typed, single spaced, must be in times new roman font (size 12) and must follow ...

Question in a sequence diagram how do you represent a newly

Question : In a sequence diagram, how do you represent a newly created object? What is the difference between components and artifacts?

Can someone please help me with this examthis is consists

can someone please help me with this exam This is consists of four questions. The questions are designed to test your understanding of certain concepts that were studied over the course of the semester. Please answer all ...

With more persons working from home how does one separate

With more persons working from home, how does one separate data intended for the employer form what might be considered personal property? What policies could be put in place to ensure employees adhere to safe guidelines ...

Python programmingplease i would like some help in checking

Python programming Please I would like some help in checking if my source code for is susceptible to short-circuit evaluation.I don't need answers, I just need corrections. The source code is to check the integer parts o ...

Question show the dynamic programming table of the longest

Question : Show the dynamic programming table of the longest common subsequence problem for two sequences: S1 = ABAABBA and S2 = BAAABAB. Also show how to find the LCS itself from the table.

  • 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