import torch


def get_cumulant(h, a, terminal_a, food_type, index):
    """
        h: history
        a: action
        terminal_a: index of the terminal action = |A| + 1
        food_type: type of food item from {(0, 1), (1, 0), (1, 1)}
        index: index of the resource for which the cumulant value is required
    """
    if a == terminal_a:
        return torch.tensor(0.)
    if not h[index] and food_type[index]:
        return torch.tensor(food_type[index] * 1.)
    elif h[index]:
        return torch.tensor(-1.)
    return torch.tensor(0.)