rfrapp 17 Junior Poster in Training

My assignment is to create the Game of Life. I know that it is very easy to find out how to do this online, but I don't want the answers fed to me. Here's what I have so far:

// Life.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <ctime>

using namespace std;

void generation(char[][20], int);
void neighbors(char[][20], int);
void display(char[][20], int);

int _tmain(int argc, _TCHAR* argv[])
{
	int x = 0;
	char board[70][20];

	srand(time(NULL));

	for (int x = 0; x < 70; x++)
	{	
		for (int y = 0; y < 20; y++)
		{
			board[x][y] = 'X';
			//cout << board[x][y];
		}
	}
	cout << endl;
	generation(board, 70);
	

	system("pause");
	return 0;
}

void generation (char board[][20], int size)
{
	char symbol = 'X';
	int x = 0;	
	int number;
	for (int x = 0; x < 70; x++) //uses rand to populate the board
	{
		for (int y = 0; y < 20; y++)
		{
			number = rand() % 100 + 1;
			if (number > 50)
				board[x][y] = symbol;
			else 
				board[x][y] = ' ';
			cout << board[x][y];
		}		
	}	
	do 
	{
		neighbors(board, 70);
		x++;
		system("pause");
		system("cls");
	} while(x < 50);	
	//display(board, 70);

	//system("pause");
	//system("cls");
}

void neighbors(char board[][20], int size)
{
	char newBoard[70][20];
	for (int x = 0; x < 70; x++)
		for (int y = 0; y < 20; y++)
		{
			newBoard[x][y] = board[x][y];
			//this would fullfill the requirement for overpopulation
			if (newBoard[x][y] == 'X')
			if (board[x][y - 1] == 'X' && board[x][y + 1] == 'X' && (board[x - 1][y] == 'X' || board[x + 1][y] == 'X'))
				newBoard[x][y] == ' ';
		}
		display(newBoard, 70);
}

void display(char newBoard[][20], int size)
{
	for (int x = 0; x < 70; x++)
	{
		for (int y = 0; y < 20; y++)
		{
			cout << newBoard[x][y];
		}
	}
	cout << endl;

}

For some reason, my array is not being populated with the full amount of X's. Can anyone tell me why that is? And where might I go from here in my code? If you'd take the time to examine my code, then I'd really appreciate it. Tnanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.