Can you guys help me build conway's game of life? I don't need anyone to build it for me, but if you could help me work through it, I have no idea how to implement the rules correctly.
Here is the basic board which I have set up so far..
#include <iostream>
using namespace std;
#include <conio.h>
#include <memory.h>
#include <time.h>
void main ()
{
const long NumCols (20);
const long NumRows (20);
const long WaitTime (2);
bool Board [NumRows] [NumCols];
long Col;
long Generation;
long i;
long NumCellsToOccupy;
long Row;
time_t StartTime;
memset (Board, 0, sizeof (Board));
do {
cout << "How many cells do you want occupied? ";
cin >> NumCellsToOccupy;
} while ((NumCellsToOccupy <=0) || (NumCellsToOccupy > (NumRows * NumCols)));
for (i = 0; i < NumCellsToOccupy; i++)
{
do {
cout << "Enter the row and col for occupied cell #" << (i + 1) << ": ";
cin >> Row >> Col;
} while ((Row < 1) || (Row > NumRows) || (Col < 1) || (Col > NumCols));
Board [Row - 1] [Col - 1] = true;
}
Generation = 0;
do {
cout << "Generation: " << Generation << endl;
for (Row = 0; Row < NumRows; Row++)
{
for (Col = 0; Col < NumCols; Col++)
cout << (Board [Row] [Col] ? '*' : ' ');
cout << endl;
}
StartTime = time (0);
do {
} while ((time (0) - StartTime) < WaitTime);
Generation ++;
} while (!_kbhit ());
}