def compute_neighbour_sum(is_black, source, row, col):
    """
    Calculate the neighbour sum of an individual spin at given position.

    :param is_black: States whether the updated spin is located in the "black"
        or in the "white" array according to the checkerboard algorithm.
    :type is_black: bool
    :param source: The array containing the neighbour spins.
    :type source: `np.ndarray`
    :param row: The row of the spin to compute the neighbour sum of.
    :type row: int
    :param col: The column of the spin to compute the neighbour sum of.
    :type col: int

    :return: The neighbour sum.
    :rtype: int

    """
    grid_height, grid_width = source.shape

    lower_neighbor_row = row + 1 if (row + 1 < grid_height) else 0
    upper_neighbor_row = row - 1
    right_neighbor_col = col + 1 if (col + 1 < grid_width) else 0
    left_neighbor_col = col - 1

    if is_black:
        horizontal_neighbor_col = left_neighbor_col if row % 2 else right_neighbor_col
    else:
        horizontal_neighbor_col = right_neighbor_col if row % 2 else left_neighbor_col

    neighbour_sum = (
        source[upper_neighbor_row, col]
    +   source[lower_neighbor_row, col]
    +   source[row, col]
    +   source[row, horizontal_neighbor_col]
    )
    return int(neighbour_sum)