Skip to content
DeepForgeby svx
All problems

Eligibility Trace Update

Problem

Update an accumulating eligibility trace for one state visit.

Decay every entry by gamma * lam, then add 1.0 to trace[s]. Return the new trace without mutating the input.

Hint

Decay first, then bump the visited state so its trace is exactly 1.

Test cases

case 1
in: [[0,0],0,0.9,0.5]
expected: [1,0]
case 2
in: [[1,0.5],1,0.9,0.5]
expected: [0.45,1.225]
case 3
in: [[0.2,0.4,0.6],2,1,1]
expected: [0.2,0.4,1.6]
Starter codePython
def eligibility_trace_update(trace, s, gamma, lam):
    # Your code here
    pass

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