All problems
Potential Shaping Reward
Problem
Compute the potential-based shaping reward F(s, s') = gamma * phi(s') - phi(s). This form provably leaves the optimal policy unchanged.
Hint
Any shaping shaped like a discounted potential difference preserves optimal policies.
Test cases
case 1
in: [1,2,0.9]
expected: 0.8
case 2
in: [0,0,0.9]
expected: 0
case 3
in: [5,1,0.5]
expected: -4.5
case 4
in: [-2,3,1]
expected: 5
Starter codePython
def potential_shaping_reward(phi_s, phi_s_next, gamma):
# Your code here
pass4 test cases · run your code against them in the editor