Skip to content
DeepForgeby svx
All problems

TD(0) Update

Problem

Apply a one-step TD(0) update to the value table and return the updated copy.

V[s] becomes V[s] + alpha * (r + gamma * V[s_next] - V[s]). Do not mutate the input list.

Hint

Copy the list first, then move V[s] toward the bootstrapped target by alpha.

Test cases

case 1
in: [[0,0],0,1,1,0.1,0.9]
expected: [0.1,0]
case 2
in: [[1,2],1,0,0,0.5,1]
expected: [1,1.5]
case 3
in: [[3,4,5],0,2,2,0.2,0.9]
expected: [3.7,4,5]
Starter codePython
def td0_update(V, s, r, s_next, alpha, gamma):
    # Your code here
    pass

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