All problems
Elo Self-Play Update
Problem
Update player A's Elo rating after a self-play game.
E = 1 / (1 + 10 ** ((rating_b - rating_a) / 400)), and the new rating is rating_a + k * (score - E), where score is 1.0 for a win, 0.5 for a draw, and 0.0 for a loss.
Hint
Beating a stronger opponent moves the rating more than beating a weaker one.
Test cases
case 1
in: [1500,1500,1,32]
expected: 1516
case 2
in: [1500,1500,0.5,32]
expected: 1500
case 3
in: [1600,1400,0,20]
expected: 1584.8050614670408
case 4
in: [1400,1600,1,20]
expected: 1415.1949385329592
Starter codePython
def elo_self_play_update(rating_a, rating_b, score, k):
# Your code here
pass4 test cases · run your code against them in the editor