All problems
Virtual Loss Apply
Problem
Apply a virtual loss to a node so parallel MCTS workers spread out.
Return [[w - virtual_loss for w in wins], [v + 1 for v in visits]], discouraging other workers from selecting the same path.
Hint
The virtual visit count also lowers the node's average value.
Test cases
case 1
in: [[3,1],[2,4],1]
expected: [[2,0],[3,5]]
case 2
in: [[0],[0],0.5]
expected: [[-0.5],[1]]
case 3
in: [[],[],2]
expected: [[],[]]
case 4
in: [[2,-1],[5,2],0.25]
expected: [[1.75,-1.25],[6,3]]
Starter codePython
def virtual_loss_apply(wins, visits, virtual_loss):
# Your code here
pass4 test cases · run your code against them in the editor