Game is thus parameterized by the particular population

Assignment Help Basic Computer Science
Reference no: EM13954413

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.

Reference no: EM13954413

Questions Cloud

How did miriam fare with her alternative lease arrangement : How did Miriam fare with her alternative lease arrangement? Would she have been better off with a flat $100,000 lease payment?
Solving for stockholders equity amounts : Assume that the following amounts are known for Colten Company for the current year:
The team and the contribution of key members to team purpose : Continue to use the organization you selected for your final project in Week 1. This week, you are being placed on a ten-person virtual team. You are quite excited and want yourself and the team to be very successful.
Convert the table to a probability table by dividing : What is the probability that a person is color blind, given that the person is a male?
Game is thus parameterized by the particular population : 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 w..
Discuss how diversity impact leadership in homeland security : Describe and discuss how diversity impacts leadership in Homeland Security and Emergency Management - describe and Discuss the hiring process associated with filing entry-level first responder positions.
Stockholders equity accounts : MJ Company has identified the following items. Indicate whether each item is included in an account in the Stockholders' Equity category of the balance sheet and identify the account title. Also, indicate whether the item would increase or decreas..
How long ago were elements that formed our earth released : A threory of nuclear astrophysics is that all the heavy elements like uranium are formed in supernova explosions of massive stars, which immediately release the elements into space. If we assume that at the time of the explosion there were equal a..
How close would the alpha get to a copper nucleus : What is the distance of closest approach of an alpha particle of speed v= 1.70 x10^7 m/s to a gold nucleus of Z = 79? How close would the alpha get to a copper nucleus of Z = 29? Assume that the gold and copper nuclei remain at rest.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Write the code for invoking a method

Write the code for invoking a method named sendSignal . There are no arguments for this method. Assume that sendSignal is defined in the same class that calls it.

  Explain the conceptual model employed in the design

Explain the conceptual model employed in the design of these types. Describe the analogies and concepts these monitors expose to users, including the task-domain objects users manipulate on the screen.

  Discuss the the role mobile technologies

Discuss the the role mobile technologies can play in the launch of a new product

  For the term lambdax x lambday y write down the type of

1 beta-reductiona underline the free variables in the term lambday x. x y a. a x b beta-reduce that term to its normal

  Write one java statement that creates an array of integers

Write one Java statement that creates an array of integers containing the multiples of 10 between 10 and 100, including 10 and 100.

  Green computing research

Green Computing Research Project, Part 2 in Appendix CCongratulations!You have been selected as the project manager for the Green Computing Research Project.  The company's CIO, Ben, is the project sponsor, and Ito is the program manager for the larg..

  The relevant theory and/or research inform

What specifically worked well? How do I know it worked well? What specifically worked least well? Why do I think that?

  As a beginning business analyst

As a beginning business analyst, you have been tasked by the project manager to develop the system requirements related to the handling of outstanding purchase orders.

  Responsibility of the engineer project manager

Discuss the above statement and the role and responsibility of the Engineer Project Manager in advising the client through the overall strategic decision process in order to select the most appropriate procurement system for either a private or pu..

  What might affect a spreadsheet developers choice

Excel allows you to display a system date using the date stamp and the NOW function. When might a date stamp be important? Why? What might affect a spreadsheet developer's choice for the date format used to display the date.

  Determine the number of distinct labelling of knn do the

1. determine the number of distinct labelling of knn. do the same for kmm and kmnl2. give an example of a graph g with

  Java how to program 10th edition

Java How To Program 10th Edition

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