"Game of Life" program

I'm trying to program the Game of Life, where you activate a few cells on a board and determine which ones live and die based on the neighbors they have. I was told that it's pretty simple but it's going over my head and driving me crazy with how complex it seems. It involves a boolean board and activating cells based on the number value that they hold

Here's the code I have so far. I changed a for loop with advice from my professor, but that stopped the board from even showing up



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <iostream>
#include <memory.h>
#include <stdlib.h>
#include <time.h>


using namespace std;


void main()
{

	// Create the rows and columns for the board
const int Maxcol  (60);

const int Maxrow  (60);

const time_t waittime  (5);

bool Board [Maxcol + 2] [Maxrow + 2];

  // Declare variables
int i;

int Gen;

int Row;

int Col;

int NumCells;

time_t stoptime;



  // Set up the board
memset (Board, false, (Maxrow + 2) * (Maxcol + 2) * sizeof (bool));
	
// Replace with for loop
	for (i = 0; i < Maxrow; i++)
		Board [i] [i] = true;

// The code I'll replace it with that stops the board from showing up
	// cout << "How many cells to activate?";
	// Cin >> NumCells

	// for (i = 0; i < NumCells; i++)
	// {
	// cin >> Row >> Col;
	// Board [Row] [Col] = true;
	// } 


	for (Gen = 0; ; Gen++)
	{
		system ("cls");
		cout << "\tGeneration : " << Gen << endl;
		
		for (Row = 0; Row < Maxrow; Row++)  //		Display this generation
	  {
		  for (Col = 0; Col < Maxcol; Col++)
			  cout << (Board [Row] [Col] ? '*' : ' '); 
		    cout << endl;


	}




	stoptime = time (0) + waittime;
	while (time (0) < stoptime);






	}

}
Topic archived. No new replies allowed.