Tag: Elo rating

  • Elo Rating – How to match with an opponent with equal strength.

    Well, the Tata Steel Chess Tournament is going on in the Netherlands, where the best Chess Players in the world, including Magnus Carlsen, are playing. They have insane chess ratings like Ding and Carlsen are rated 2800+ while the lowest rated player is 2681. Now that is some tough competition. With my measly rating of around 1200, I would not stand a chance. But the question remains, how do you come up with these ratings?

    This question must have also perplexed Arpad Elo, the inventor of the Elo rating system. It tries to measure the relative skill of players in zero-sum games such as Chess. A zero-sum game is just a fancy word for saying a game where one side loses and the other side wins, or it is a draw, it cannot happen that both sides walk away with an advantageous result.

    How to Calculate it?

    Support player A has a rating of RA and player B has a rating of RB. Then we calculate the expected probability of a win for each of the players using the formula –

    P_{A} = \frac{1}{1+{10^{(R_{B}-R_{A})/400}}}

    P_{B} = \frac{1}{1+{10^{(R_{A}-R_{B})/400}}}

    After the match player A scores SA points then we will update his rating according to the formula –

    R_{A}^{new} = R_{A} + k(S_{A} - P_{A}) where the k-factor determines how the rating reacts to new results. If the value is set too high the ratings will jump around too much and if set too low it will take a long time to recognize greatness.

    Let’s take an example. If Magnus plays against Fabi, then

    #Function to calculate expected points
    
    def expected_points(x,y):
        return 1/(1+10**((y-x)/400))
    
    #Live ratings
    r_magnus = 2850
    r_fabi = 2768
    
    #Expected points
    e_magnus = expected_points(r_magnus, r_fabi)
    e_fabi = expected_points(r_fabi, r_magnus)
    #e_magnus = 0.615864104253756
    #e_fabi = 0.384135895746244)
    # If we assume that fabi wins, and a k-factor of 16, then
    
    def new_rating(rating, k, points, expected_points):
        return rating + k*(points - expected_points)
    
    magnus_new_rating = new_rating(r_magnus, 16, 0, e_magnus)
    fabi_new_rating = new_rating(r_fabi, 16, 1, e_fabi)
    

    Once you do the calculation, you will see that Magnus’s rating is 2840 and Fabi’s rating is now 2777.

    Had Fabi lost, his rating would not go down as drastically as Magnus’s did when he lost, for example, if Fabi lost in this example, his rating will be 2761.85, so he lost lesser points when losing to a higher-rated opponent, but gains a lot if he manages to beat one. Spoiler alert – Fabi lost against Magnus in the Tata Steel Chess Tournament.

    Hopefully, this post made it a bit clear how you can calculate Elo Ratings and how are they calculated for Chess Players. Fun fact, these ratings are calculated behind the scenes of almost every multi-player game to ensure that they always match you to an opponent of similar skill.