All problems
N-Step Window Return
Problem
Compute the discounted return inside a window of an episode.
Starting at index start, sum gamma^k * rewards[start + k] for the first n available rewards, truncating at the end of the episode. Return 0.0 when start is out of range or n is 0.
Hint
This is the raw n-step reward sum with no bootstrap term.
Test cases
case 1
in: [[0,1,2,3,4],1,3,0.5]
expected: 2.75
case 2
in: [[1,2,3],0,5,0.9]
expected: 5.23
case 3
in: [[1,2],5,2,0.9]
expected: 0
case 4
in: [[2,4],0,0,0.9]
expected: 0
Starter codePython
def n_step_window_return(rewards, start, n, gamma):
# Your code here
pass4 test cases · run your code against them in the editor