15 lines
798 B
Text
15 lines
798 B
Text
Assume an array of cells with an initial distribution of live and dead cells,
|
|
and imaginary cells off the end of the array having fixed values.
|
|
|
|
Cells in the next generation of the array are calculated based on the value of the cell and its left and right nearest neighbours in the current generation.
|
|
|
|
If, in the following table, a live cell is represented by 1 and a dead cell by 0 then to generate the value of the cell at a particular index in the array of cellular values you use the following table:
|
|
|
|
0'''0'''0 -> 0 #
|
|
0'''0'''1 -> 0 #
|
|
0'''1'''0 -> 0 # Dies without enough neighbours
|
|
0'''1'''1 -> 1 # Needs one neighbour to survive
|
|
1'''0'''0 -> 0 #
|
|
1'''0'''1 -> 1 # Two neighbours giving birth
|
|
1'''1'''0 -> 1 # Needs one neighbour to survive
|
|
1'''1'''1 -> 0 # Starved to death.
|