Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use a Java language when considering this problem Life is a mathematical game invented by mathematician, John Conway. It became widely popular after it

Please use a Java language when considering this problemimage text in transcribedimage text in transcribedimage text in transcribed

Life is a mathematical "game" invented by mathematician, John Conway. It became widely popular after it was published in a column in Scientific American in 1970. It is one of the most commonly programmed games on the computer. Life is an example of a cellular automaton, a system in which rules are applied to cells and their neighbors in a regular grid. Life is played on a rectangular grid of square cells. Each of these cells are either dead or alive. Here are the rules for Life: Each cell has eight (8) neighbors Once started, the state of a cell depends on its current state and the state of its neighbors If a dead cell has exactly three (3) live neighbors, it becomes alive. This is a birth. 1 2 3 1 If a dead cell does not have exactly three (3) live neighbors, it remains dead If a live cell has two (2) or three (3) live neighbors, it remains alive. This is survival. 2 If a live cell has zero (0) or one (1) live neighbors, it dies. This is loneliness. If a live cell has four (4) or more live neighbors, it dies. This is overcrowding These rules are applied to all of the cells at one time. That is, the new state of each cell is determined before changing the state of any of the cells. Instructions Command-Line Game of Life Life is designed to run in a grid of infinite size. John Conway initially created Life on a Go board, 19 x 19. We will use this simplification for our implementation Create a class to implement Life. The implementation can use a two-dimensional array to represent the cells in the game. Override the subclass Object's toString) method to allow System.out.println() to print out your game board. You will convert the game board field (a two dimensional array) into a String and return that. For example, if you use "." to represent dead cells and "O" to represent live cells, a spaced out grid of characters works well This example uses one space between each character that represents a cell. Due to the ratio of height to width of many printing fonts, this spacing makes the cells relatively square In the application method, provide an initial state for your game. Print out the initial state by calling "System.out.println(game)" (or whatever you call your game of Life object). System.out.println will call your objects toString method to convert your game board into a String in order to print it to the console Next Generation Update the game to display the next generation. If you used the previous example as a starting point, the second generation would appear as follows In this example, the changed cells are shown in red with a yellow background. There is no need to indicate which cells changed in your output. Just use System.out.println(game) to output the updated matrix (just like for outputting the initial state) Please ensure that your starting point includes some static patterns (like the block and beehive), some patterns that will die off (like the two-cells in the upper left), and some alternating patterns (like the blinker in the lower right). You can include a glider as well, if you like (lower left). For more information about these patterns, see the additional notes about Life. Note: You need to determine the values for the next generation of cells completely before changing the state of the cells There are several ways to do this. You may use two arrays, the current generation and next generation. Alternately, you could use different codes to indicate birth, survival, loneliness, overcrowding. Both of these schemes have their own complexities Note: This part of the assignment is about data manipulation. The output using System.out.println(game) and the lack of input are simplifications for this part of the assignment. Later parts of this assignment will enhance the output (graphics) and provide a means to input a starting state

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Support For Data Mining Applications Discovering Knowledge With Inductive Queries Lnai 2682

Authors: Rosa Meo ,Pier L. Lanzi ,Mika Klemettinen

2004th Edition

3540224793, 978-3540224792

More Books

Students also viewed these Databases questions