void matdis(char a1[5][5]) // It displays char array
{
for(int u = 0; u<5; u++)
{
for(int g = 0; g<5; g++)
{
cout<<a1[u][g]<<" ";
}
cout<<endl;
}
}
void transcriptor(int a1[5][5], char a2[5][5]) // It translates int into char for display
{
for(int i = 0; i<5; i++)
{
for(int j = 0; j<5; j++)
{
if(a1[i][j]==1)
{
a2[i][j] = 'x';
}
else if(a1[i][j]==0)
{
a2[i][j] = '\0';
}
}
}
}
int nsum(int a1[5][5], int i, int j) // Calculates sum of diagonal elements
{
int sum = a1[i-1][j-1] + a1[i][j-1] + a1[i+1][j-1] + a1[i+1][j] + a1[i+1][j+1] + a1[i][j+1] + a1[i-1][j+1] + a1[i-1][j];
return sum;
}
int main() // All the rest
{
int t = 0; int a1[5][5]; int a2[5][5];
char a3[5][5];
cout<<" \t\t Welcome to the Game of Life "<<endl;
cout<<" \t Provide the automaton with initial conditions, and see it proceed"<<endl;
for(int a = 0; a<5; a++)
{
for(int b = 0; b<5; b++)
{
a2[a][b]='\0';
}
}
for(int i = 0; i<5; i++)
{
for(int j = 0; j<5; j++)
{
cin>>a1[i][j];
}
}
int stopcon = 1;
while(stopcon)
{
for(int y = 0; y<5; y++)
{
for(int z = 0; z<5; z++)
{
a3[y][z] = '\0';
}
}
if(t%2==0)
{
rules(a1,a2);
transcriptor(a2,a3);
matdis(a3);
}
else
{
rules(a2,a1);
transcriptor(a1,a3);
matdis(a3);
}
cout<<" Go for another generation? Y : 1 . N : 0 "<<endl;
cin>>stopcon;
t++;
}
getch(); return 0;
}