Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

***JAVA problem! Game Of Life In 1970, mathematician John Conway developed the G

ID: 3677547 • Letter: #

Question

***JAVA problem!

Game Of Life

In 1970, mathematician John Conway developed the Game of Life (no, not the board game). Imagine a grid of cells, each cell in one of two states: alive or dead. Each cell interacts with its eight neighbors so that, over time, life in the cells will either begin or end, following a simple set of rules:

Any live cell with fewer than two live neighbors will die (from loneliness, perhaps)

Any live cell with two or three live neighbors remains alive

Any live cell with more than three live neighbors will die (from overcrowding, perhaps)

Any dead cell with exactly three live neighbors will become alive

When the main program begins, the user will input the number of time steps to be shown, the size of the grid (always square), and then the initial grid values. The size of the grid will be determined by the original input and will not change while the program is running. For simplicity, we will assume that any neighboring cells beyond the edges of the grid are dead. In the initial values and in the output, use "-" to indicate dead cells and "O" to indicate live cells (although you may of course represent these internally however you like (a boolean array, for example)). Running the program will look like the examples below.

Explanation / Answer

import java.io.*; import java.util.Random; public class Life { private boolean[][] cells; public static void main( String[] args ) { Life generation = new Life( ); for (int i = 0; i != 10; i++) { System.out.println( generation ); generation.next( ); } } // Constructors public void next (){ int SIZE; SIZE=cells.length; boolean[][] tempCells = new boolean [SIZE] [SIZE]; for (int row = 0; row