Wednesday, March 24, 2010

Wednesday, March 17, 2010

lab assignment:
research (Google) printf and scanf, and how you would use & in the context of scanf. write a simple program that uses each of these, to print and read an int, a double, and a C string (array of characters)

implement conway's game of life:

start out with initial board setup
int current_generation[20][20];
int next_generation[20][20];

// set up the first configuaration (read from a file)
while(true)
{
    // apply 4 rules to fill in next_generation,
    // based on current_generation

//   1. Any live cell with fewer than two live neighbours dies, as if caused by underpopulation.
//   2. Any live cell with more than three live neighbours dies, as if by overcrowding.
//   3. Any live cell with two or three live neighbours lives on to the next generation.
//   4. Any dead cell with exactly three live neighbours becomes a live cell.

    // make current_generation the same as next_generation
    // copy the contents of next_gen into curr_gen
    for (i = 0; i < 20; i++)
        for (j = 0 ; i < 20; j++)
            A[i][j] = B[i][j];

    // print to screen or the board the contents of cur_gen

}