Skip to content
Snippets Groups Projects
Commit 4289214d authored by Leonardo Krambeck's avatar Leonardo Krambeck
Browse files

corrige checkNeighbors

parent 08fa1429
Branches
No related tags found
No related merge requests found
......@@ -186,12 +186,12 @@ int checkNeighbors (game_t *game, int x, int y)
{
int i, j, aliveCellCount = 0;
printf ("bruh\n");
for ( i=-1; i <= 1; i++ )
for ( j=-1; j <= 1; j++ )
if ( !( (x+i < 0) || (y+j < 0) || (x+i > game->this.rows) || (y+j > game->this.cols) ) )
if ( (x!=0) || (y!=0) )
/* Checks if the coordinate is inside the matrix. */
if ( !( (x+i < 0) || (y+j < 0) || (x+i >= game->this.rows) || (y+j >= game->this.cols) ) )
/* Make sure to not compare with the middle cell. */
if ( !( (i==0) && (j==0) ) )
if ( game->this.generation[x+i][y+j] == 1 )
aliveCellCount++;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment