All problems
Self-Play Reward
Problem
Return the terminal reward for a self-play player from the final score.
player is 0 or 1; the reward is 1.0 for a win, -1.0 for a loss, and 0.0 for a draw.
Hint
Flip the scores when the queried player is the second one.
Test cases
case 1
in: [3,1,0]
expected: 1
case 2
in: [1,3,0]
expected: -1
case 3
in: [2,2,1]
expected: 0
case 4
in: [1,3,1]
expected: 1
Starter codePython
def self_play_reward(score_a, score_b, player):
# Your code here
pass4 test cases · run your code against them in the editor