Jump to content

Online Elo Calculator


Recommended Posts

The code can be found here: xpartamupp/elo.py / xpartamupp/echelon.py

I used extendsclass.com/python.html to calculate it.

# take inputs
rating = float(input("Your Rating: "))
#If there is no rating, use 1200
opponent_rating = float(input("Opponent Rating: "))
#If no games being played use 0
games_played = float(input("Your Total Games: "))

if rating < -2199 or opponent_rating < -2199:
        raise ValueError('Too small rating given: rating: %i, opponent rating: %i' %(rating, opponent_rating))

RESULT_WIN = 1
RESULT_LOSS = -1
ELO_SURE_WIN_DIFFERENCE = 600
ELO_K_FACTOR_CONSTANT_RATING = 2200
VOLATILITY_CONSTANT = 20
ANTI_INFLATION = 0.015
rating_k_factor = 50.0 * (min(rating, ELO_K_FACTOR_CONSTANT_RATING) / ELO_K_FACTOR_CONSTANT_RATING + 1.0) / 2.0
player_volatility = (min(max(0, games_played+1), VOLATILITY_CONSTANT) / VOLATILITY_CONSTANT + 0.25) / 1.25
volatility = rating_k_factor * player_volatility
rating_difference = opponent_rating - rating
rating_adjustment_win = (rating_difference + RESULT_WIN * ELO_SURE_WIN_DIFFERENCE) / volatility - ANTI_INFLATION
rating_adjustment_lost = (rating_difference + RESULT_LOSS * ELO_SURE_WIN_DIFFERENCE) / volatility - ANTI_INFLATION
    
points_you_gain = (round(max(0.0, rating_adjustment_win)))
points_you_lose = (round(min(0.0, rating_adjustment_lost)))
new_rating_win = rating + points_you_gain
new_rating_lose = rating + points_you_lose

print('Current rating: %i\nPoints you would gain: %i (%i)\nPoints you would lose: %i (%i)' %(rating, points_you_gain, new_rating_win, points_you_lose, new_rating_lose))

Example: seeh vs Langbart

  • Seeh rating = 1059
  • Langbart rating = 1434
  • Seeh total games = 116

Points you would gain: 26 (1085)
Points you would lose: -6 (1053)

Example: seeh vs valihrant

  • Seeh rating = 1059
  • valihrant rating = 2340
  • Seeh total games = 116

Points you would gain: 51 (1110)
Points you would lose: 0 (1059)

It would be a good addition if these numbers were displayed in the lobby profile when you select a person from the playerlist. I will try to work this into the mod.

  • Like 3
Link to comment
Share on other sites

  • 4 weeks later...
On 25/10/2021 at 12:41 AM, Langbart said:

It would be a good addition if these numbers were displayed in the lobby profile when you select a person from the playerlist. I will try to work this into the mod.

thats very cool plan. and ty for the only link :thumbsup:
BTW this source in other python online interpreters: https://www.online-python.com/wvGLoTZg70

Edited by seeh
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...