I run the program and nothing prints out..
#include <iostream>
#include <vector>
#include <windows.h>
using namespace std;
void check_neighbors(vector<vector<char> >, int [22][88]);
void generation(vector<vector<char> >);
void display(vector<vector<char> >);
int main()
{
vector<vector<char> > world(22, vector<char>(88, '.'));
int neighborArray[22][80];
//Intial condiion
world[3][3] = '*';
world[3][4] = '*';
world[4][4] = '*';
world[3][7] = '*';
world[5][6] = '*';
world[5][7] = '*';
world[5][8] = '*';
for(int c = 0; c < 3;c++)
{
//
generation(world);
cout << "here" << endl;
Sleep(1000);
display(world);
}
return 0;
}
void check_neighbors(vector<vector<char> > globe, int neighborArr[22][80])
{
for(int i = 2;i < 20;i++)
{
for(int j = 2;j < 79;j++)
{
int neighbors = 0;
if(globe[i+1][j+1]=='*')
{
neighbors +=1;
}
if(globe[i][j-1]=='*')
{
neighbors +=1;
}
if(globe[i+1][j-1]=='*')
{
neighbors +=1;
}
if(globe[i-1][j]=='*')
{
neighbors +=1;
}
if(globe[i-1][j+1]=='*')
{
neighbors +=1;
}
if(globe[i][j+1]=='*')
{
neighbors +=1;
}
if(globe[i+1][j-2]=='*')
{
neighbors +=1;
}
if(globe[i+1][j]=='*')
{
neighbors +=1;
}
neighborArr[i][j] = neighbors; //no errors in this method
}
}
}
void generation(vector<vector<char> > env)
{
int neighborArray[22][80];
for(int i = 0;i < env.size();i++)
{
check_neighbors(env, neighborArray); //error here, no erros above, no errors below
for(int j = 0;j < env[i].size();j++)
{
if(env[i][j] == '*')
{
if(neighborArray[i][j] < 2)
{
env[i][j] = '.';
}
if(neighborArray[i][j] > 3)
{
env[i][j] = '.';
}
}
else
{
if(neighborArray[i][j] = 3)
{
env[i][j] = '*';
}
}
}
}
}
void display(vector<vector<char> > grid)
{
for(int x = 0; x < grid.size(); x++)
{
for(int y = 0;y < grid[x].size();y++)
{
cout << grid[x][y];
}
cout << endl;
}
}