Skip to content
DeepForgeby svx

Problem

Compute the one-step temporal-difference error: delta = reward + gamma * next_value - value. This is the residual between the bootstrapped target and the current estimate.

Hint

It is the reward plus discounted next value minus the current value estimate.

Test cases

case 1
in: [1,2,3,0.9]
expected: 1.7000000000000002
case 2
in: [0,0,0,0.9]
expected: 0
case 3
in: [-1,2,1,0.5]
expected: -2.5
case 4
in: [5,5,5,1]
expected: 5
Starter codePython
def td_error(reward, value, next_value, gamma):
    # Your code here
    pass

4 test cases · run your code against them in the editor