I am trying to code a "Conways Game of Life" Visualization. I think I have a solid idea on how to go about it but my issue I am running into is this: When I attempt to output the rows and columns of my 2d array, it starts jumping between numbers towards the end and it never stops scrolling the numbers. It seems to get caught on the "x" of 78.
#include <iostream>
#include <cstring>
#include <cstdlib>
#define HEIGHT 25
#define WIDTH 80
using namespace std;
void makeBoard();
int seed = 0;
int main()
{
makeBoard();
}
void makeBoard()
{
int board[79][24] = {0};
/* Seed the random number generator with the specified seed */
srand(seed);
for(int x = 0; x <= 79; x++)
{
for(int y = 0; y <= 24; y++)
{
/* 50% chance for a cell to be alive */
if(rand() % 100 < 50)
{
board[x][y] = {1};
}
else
{
board[x][y] = {0};
}
/*if(board[x][y] == 1) {
cout << "SPAM" << endl;
}*/
//this is just printing out the current location it is iterating through.
cout << "X: " << x << " Y: " << y << endl;
}
cout << endl;
}
}
all of the code needed to run it should be right there.
Thank you for your help and patience.