def calc_delayed_rewards(rewards, gamma):
    """
    calculates the ReLeaSE style of rewards:
    R(s_t) = gamma^t * r(s_T)

    :param rewards:
    :param gamma:
    :return:
    """
    vals = []
    discounted_reward = rewards[-1]
    for _ in range(len(rewards)):
        vals.append(discounted_reward)
        discounted_reward = discounted_reward * gamma
    return vals