All problems
Invalid Action Penalty
Problem
Penalize an action that is not in the valid action list.
Return reward if action is valid, otherwise reward - penalty.
Hint
This is a soft alternative to hard action masking.
Test cases
case 1
in: [1,2,[0,1,2],5]
expected: 1
case 2
in: [1,3,[0,1,2],5]
expected: -4
case 3
in: [0,0,[],2]
expected: -2
case 4
in: [-1,1,[1],0.5]
expected: -1
Starter codePython
def invalid_action_penalty(reward, action, valid_actions, penalty):
# Your code here
pass4 test cases · run your code against them in the editor