/* THE GAME OF LIFE Written and produced by Chris C. Keeser on 6/8/04 sitting on my couch listening to music at 12:30 in the morning oh what a good feeling that was. (seriously, it was the most peace I have had all week) */ #include "life.hxx" //////////////////////////////////////////// /* NAME: SHOW_GENERATION DESCRIPTION: This lady "modifies the array from it original version to be formatted for your viewing pleasure" PAPRAMETERS: Give me an array (100 X 100) please, and I will display it with a nice border and clean up all those ugly 1's and 0's into blank spaces and 0's. PRE-CONDITIONS: There must exist an array of size 100 X 100 POST-CONDITIONS: You must look at the screen to see my hard work RETURN: none. its a void function. SIDE EFFECTS: You get to see the world you have created. */ ///////////////////////////////////////////// void show_generation(int planet[MAXR][MAXC]) { system("cls"); //Clears screen int r = 0, c = 0, n = 0; // r for Rows and c for Columns. n is our // border counter. she makes sure the top and bottom borders are just right char disp = 'X';// you can use any character to display life. give it a go! for(n = 0; n <= (MAXC + 1); n++) // top border printer { printf("="); } printf("\n"); for(r = 0; r <= (MAXR - 1); r++) // row counter, start at row 0 and go to row 99 { printf("|"); // at the beginning of each new row print an '|' for border for(c = 0; c <= (MAXC - 1); c++) // column counter, start at column 0 and go to 99 { if(planet[r][c] == 1) // if the cell is alive print the specified character { printf("%c", disp); } else // other wise just print blank space { printf(" "); } } printf("|"); // end of row, print another '|' printf("\n"); // end of row, start a new display row } for(n = 0; n <= (MAXC + 1); n++) // bottom border printer { printf("="); } printf("\n"); return; }