The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Compute one step of Conway's Game of Life. The rules and history of the Game of Life can be found here.
Summary
The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, alive or dead. Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:
The initial pattern constitutes the seed of the system. The first generation is created by applying the above rules simultaneously to every cell in the seed - births and deaths occur simultaneously, and the discrete moment at which this happens is sometimes called a tick (in other words, each generation is a pure function of the preceding one). The rules continue to be applied repeatedly to create further generations.
Requirements
void life( uint8_t array[],
unsigned int cols,
unsigned int rows );
Â
Examples
Your function must correctly compute a single step of Life, so that it can be used in a loop to create a Life simulation as shown here.
int glider[][2] = { {1,0}, {2,1}, {0,2}, {1,2}, {2,2} };
for( int i=0; i<5; i++ )
set_pixel( img, w, h, glider[i][0], glider[i][1], 255 );
for( int i=0; i<32; i++ )
{
draw_image_grey( img, w, h );
life( img, w, h );
}
draw_image_grey( img, w, h );