Hola disculpen alguin me podria ayudar con mi implementacion del juego de la vida de john conway, concretamente en la funcion comprobacion(), se agradece de ante mano.
//El juego de la vida
#include <stdio.h>
#include <windows.h>
#include <time.h>
int columnas;
void gotoxy(int x,int y);
void dibujarrejilla(int fil, int col);
void dibujarCelula(int rejilla[][columnas], int filas, int col);
void llenarRejilla(int rejilla[][columnas], int filas, int col);
void comprobacion(int rejilla[][columnas], int filas, int col);
int main(){
int filas, col;
int i, j;
printf("Coloque el numero de filas\n"); printf("Coloque el numero de columnas\n");
columnas = col;
int rejilla[filas][col];
llenarRejilla(rejilla, filas, col);
dibujarrejilla(filas, col);
do{
dibujarCelula(rejilla, filas, col);
comprobacion(rejilla, filas, col);
Sleep(1000);
//getch();
}while(1);
return 0;
}
void gotoxy(int x,int y){
HANDLE hcon;
hcon = GetStdHandle(STD_OUTPUT_HANDLE);
COORD dwPos;
dwPos.X = x;
dwPos.Y= y;
SetConsoleCursorPosition(hcon,dwPos);
}
void llenarRejilla(int rejilla[][columnas], int filas, int col){
int i, j;
for(i=0; i<filas; i++){
for(j=0; j<col; j++){
}
}
}
void dibujarrejilla(int fil, int col){
int i, j;
for(i=0; i<fil; i++){
for(j=0; j<col; j++){
if(i==0){
if(j==0){
gotoxy(i*2,j*2);
}else{
if((col-1) == j){
gotoxy(i*2,j*2);
gotoxy(i*2,(j*2-1));
}else{
gotoxy(i*2,j*2);
gotoxy(i*2,(j*2-1));
}
}
}else{
if(j==0){
gotoxy(i*2,j*2);
}else{
if((col-1) == j){
gotoxy(i*2,j*2);
gotoxy(i*2,(j*2-1));
}else{
gotoxy(i*2,j*2);
gotoxy(i*2,(j*2-1));
}
}
if((fil-1) == i){
if(j==0){
gotoxy(i*2,j*2);
}else if((col-1) == j){
gotoxy(i*2,j*2);
}else{
gotoxy(i*2,j*2);
}
}
}
}
}
}
void dibujarCelula(int pos[][columnas], int filas, int col){
int j, i;
for(i=0; i<filas-1; i++){
for(j=0; j<col-1; j++){
if(pos[i][j] == 1){
gotoxy((i*2)+1,(j*2)+1);
}else{
gotoxy((i*2)+1,(j*2)+1);
}
}
}
}
void comprobacion(int rejilla[][columnas], int filas, int col){
int i, j, x, y, reja[filas][col], vivas;
for(i=0; i<filas; i++){
for(j=0; j<col; j++){
if(rejilla[i][j] == 0){
vivas = 0;
for(x=0; x<3; x++){
for(y=0; y<3; y++){
if((i+1)-x == i && (j+1)-y == j){
reja[i][j] = rejilla[i][j];
}else if(rejilla[(i+1)-x][(j+1)-y] == 1){
vivas++;
}
}
}
if( vivas == 3){
reja[i][j] = 1;
}
}else if(rejilla[i][j] == 1){
vivas = 0;
for(x=0; x<3; x++){
for(y=0; y<3; y++){
if((i+1)-x == i && (j+1)-y == j){
reja[i][j] = rejilla[i][j];
}else if(rejilla[(i+1)-x][(j+1)-y] == 1){
vivas++;
}
}
}
if(vivas == 2 || vivas == 3){
reja[i][j] = 1;
}else{
reja[i][j] = 0;
}
}
}
}
for(i=0; i<filas; i++){
for(j=0; j<col; j++){
rejilla[i][j] = reja[i][j];
}
}
}