# Difference: Lab7Kenyon (25 vs. 26)

#### Revision 262017-11-02 - JimSkon

Line: 1 to 1

 META TOPICPARENT name="WebHome"

# Lab 7 - Game of Life

Line: 26 to 26

### Problem

Changed:
<
<
The mathematician John Horton Conway invented the “Game of Life.” Though not a “game” in any traditional sense, it provides interesting behav- ior that is specified with only a few rules. This Project asks you to write a program that allows you to specify an initial configuration. The program follows the rules of LIFE to show the continuing behavior of the configuration. LIFE is an organism that lives in a discrete, two-dimensional world. While this world is actually unlimited, we don’t have that luxury, so we restrict the array to 80 characters wide by 22 character positions high. If you have access to a larger screen, by all means use it. This world is an array with each cell capable of holding one LIFE cell. Generations mark the passing of time. Each generation brings births and deaths to the LIFE community. The births and deaths follow the following set of rules.
>
>
The mathematician John Horton Conway invented the “Game of Life.” Though not a “game” in any traditional sense, it provides interesting behav- ior that is specified with only a few rules. This Project asks you to write a program that allows you to specify an initial configuration. The program follows the rules of LIFE to show the continuing behavior of the configuration. LIFE is an organism that lives in a discrete, two-dimensional world. While this world is actually unlimited, we don’t have that luxury, so we restrict the array to 80 characters wide by 20 character positions high. If you have access to a larger screen, by all means use it. This world is an array with each cell capable of holding one LIFE cell. Generations mark the passing of time. Each generation brings births and deaths to the LIFE community. The births and deaths follow the following set of rules.

• We define each cell to have eight neighbor cells. The neighbors of a cell are the cells directly above, below, to the right, to the left, diagonally above to the right and left, and diagonally below to the right and left.
• If an occupied cell has zero or one neighbors, it dies of loneliness. If an occupied cell has more than three neighbors, it dies of overcrowding.
Line: 35 to 35

### Notes

Changed:
<
<
Some configurations grow from relatively small starting configurations. Others move across the region. It is recommended that for text output you use a rectangular array of char with 22 rows and 80 columns to store the LIFE world’s successive generations. (char world[22][80];) Use an asterisk * to indicate a living cell, and use a blank (or space) to indicate an empty (or dead) cell. If you have a screen with more rows than that, by all means make use of the whole screen.
>
>
Some configurations grow from relatively small starting configurations. Others move across the region. It is recommended that for text output you use a rectangular array of char with 22 rows and 82 columns (the world is actually 20,80, see for why we add the extra two rows nd columns) to store the LIFE world’s successive generations. (char world[22][82];) Use an asterisk * to indicate a living cell, and use a blank (or space) to indicate an empty (or dead) cell. If you have a screen with more rows than that, by all means make use of the whole screen.
Also, it would be best if you used constants for the row number and column number, e.g.:
Line: 90 to 89

 [r+1,c-1] [r+1,c] [r+1,c+1]
Given each cell, you will write a to examine the surrounding cells to determine what happens to that cell.
Changed:
<
<
One trick is dealing with the boundary conditions, that is when something is on the edge of the array. A neat trick is to make the array one bigger in every direction, and then use this as boundary space. So if we make world[24][82], the first index r goes (top to bottom) from 0 to 23, or 24 cells, and the other index c goes (left to right) from 00 to 81. Start by making every element a space. Use these boundary cells while computing next generations, but never change or print the boundary cells. Then a boundary is really not an exception, it is just considered a dead cell with no chance for life. The boundary cells should never be displayed (they are for internal use only).
>
>
One trick is dealing with the boundary conditions, that is when something is on the edge of the array. A neat trick is to make the array one bigger in every direction, and then use this as boundary space. So if we make world[22][82], the first index r goes (top to bottom) from 0 to 21, or 22 total rows, and the other index c goes (left to right) from 00 to 81. Start by making every element a space. Use these boundary cells while computing next generations, but never change or print the boundary cells. Then a boundary is really not an exception, it is just considered a dead cell with no chance for life. The boundary cells should never be displayed (they are for internal use only).
Example:

Copyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback