avatar
Untitled

Guest 46 23rd Oct, 2019

MARKUP 0.82 KB
                                           
                         # player 1 is winner
# k-factor can be changed to determine how much you win/lose. 20 is normal. With few matches you go up to 40
# if draws are added you use 0,5 for both players instead of win/loss (1 and 0)
# win/loss (1 and 0) could be changed to other values between 0 and 1 for high wins etc.

def elo(points_player_1, points_player_2):
    k = 20;
    win = 1;
    loss = 0;
    expected_score_player_1 = 1 / (1 + 10 ** ((points_player_2 - points_player_1)/400))
    expected_score_player_2 = 1 / (1 + 10 ** ((points_player_1 - points_player_2) / 400))
    new_points_player_1 = points_player_1 + k * ( win - expected_score_player_1);
    new_points_player_2 = points_player_2 + k * ( loss - expected_score_player_2);
    return new_points_player_1, new_points_player_2

print(elo(1000, 1000))
                      
                                       
To share this paste please copy this url and send to your friends
RAW Paste Data