All problems
Action Masking Apply
Problem
Mask invalid actions by replacing their Q values with a large negative constant.
valid is a boolean list; invalid entries become -1e9 and valid entries keep their Q value.
Hint
The negative constant is finite so it stays JSON- and gradient-friendly.
Test cases
case 1
in: [[1,2,3],[true,false,true]]
expected: [1,-1000000000,3]
case 2
in: [[],[]]
expected: []
case 3
in: [[0.5],[false]]
expected: [-1000000000]
Starter codePython
def apply_action_mask(q_values, valid):
# Your code here
pass3 test cases · run your code against them in the editor