src/conway.c
int conway_neighbors(conway_t *conway, int x, int y)
{
    int i, j;
    int cx, cy;
    int neighbors = 0;

    for (i = -1; i < 2; ++i) {
        for (j = -1; j < 2; ++j) {
            if (i || j) {
                cx = (conway->num_rows + x + i) % conway->num_rows;
                cy = (conway->num_cols + y + j) % conway->num_cols;
                if (conway->universe[cx][cy].alive) {
                    neighbors++;
                }
            }
        }
    }

    return neighbors;
}
/* Returns the number of neighbors to a given point */
Returns the number of neighbors to a given point
Returns the number of neighbors to a given point
int conway_neighbors(conway_t *conway, int x, int y)
{
    int i, j;
    int cx, cy;
    int neighbors = 0;
    for (i = -1; i < 2; ++i) {
        for (j = -1; j < 2; ++j) {
            if (i || j) {
                cx = (conway->num_rows + x + i) % conway->num_rows;
                cy = (conway->num_cols + y + j) % conway->num_cols;
                if (conway->universe[cx][cy].alive) {
                    neighbors++;
                }
            }
        }
    }
    return neighbors;
}
int conway_neighbors ( conway_t * conway , int x , int y ) { int i , j ; int cx , cy ; int neighbors = 0 ; for ( i = -1 ; i < 2 ; ++ i ) { for ( j = -1 ; j < 2 ; ++ j ) { if ( i || j ) { cx = ( conway -> num_rows + x + i ) % conway -> num_rows ; cy = ( conway -> num_cols + y + j ) % conway -> num_cols ; if ( conway -> universe [ cx ] [ cy ] . alive ) { neighbors ++ ; } } } } return neighbors ; }
Returns the number of neighbors to a given point
Returns the number of neighbors to a given point