def get_neighbours(i,j,grid):
    """gets the neighbours of current cell of the current grid.

    Args:
        i (int): row number of the cell.
        j (int): column number of the cell.
        grid (np.ndarray) : the current grid.

    Returns:
        int : total number of neighbours.
    """
    
    N = len(grid)
    neighbours = 0

    for p in range(i-1, i+2):
        for q in range(j-1, j+2):

            if p == i and q == j:
                continue

            if p == N:
                p = 0
            if q == N:
                q = 0

            neighbours += grid[p][q]

    return neighbours