Skip to content
DeepForgeby svx
All problems

Regret Matching

Problem

Convert cumulative regrets into a strategy with regret matching.

Keep only the positive parts and normalize them to sum to 1. If no regret is positive fall back to a uniform distribution, and an empty list returns [].

Hint

Only actions with positive regret get probability under regret matching.

Test cases

case 1
in: [[1,-1]]
expected: [1,0]
case 2
in: [[-1,-2]]
expected: [0.5,0.5]
case 3
in: [[2,1,1]]
expected: [0.5,0.25,0.25]
case 4
in: [[]]
expected: []
Starter codePython
def regret_matching(regrets):
    # Your code here
    pass

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