Search Unity

ELO ratings for multiplayer game

Discussion in 'Scripting' started by mindlube, Mar 12, 2011.

  1. mindlube

    mindlube

    Joined:
    Oct 3, 2008
    Posts:
    993
    Hi, been doing some research on ELO type of ratings (http://en.wikipedia.org/wiki/Elo_rating_system)
    I want to implement it for multiplayer. I have been unable to find an exact formula for multiplayer on the web. But the math is pretty basic. I could just use another set of eyes on this to make sure it is sensible. Note; this is for a dominos game (no team play). For team -based multiplayer, ELO is not as appropriate.

    What I've found on the web, here is the formula
    R' = R + K ( Sa - Ea )
    where
    R' = player A new rating
    R = player A current rating
    K = KValue (e.g. commonly used 10, 15 or 25 for a provisional player)
    Sa = actual score (e.g. 1.0 win, 0.5 tie, 0.0 loss)
    Ea = expected score (from formula below)

    Ea for player B = 1 / (1 + 10 ^ ((Ra - Rb) / 400 ))
    Ea for player A = 1 / (1 + 10 ^ ((Rb - Ra) / 400 ))
    where
    Ra = player A rating
    Rb = player B rating

    OK so the part I'm not sure about, is how to expand the R' formula for the multiplayer case. It seems like one would repeat the term K(Sa-Ea) for each sub-match( a vs b, a vs. c, a vs d , in a 4 player match)

    R' = R + K ( Sa - Ea1 ) + K ( Sa - Ea2 ) ... + K ( Sa - EaN )

    I've just finished implementing this in C# and writing some tests now. Any comments or thoughts would be appreciated!

    edit:
    also here is a cool site illustrating what I'm trying to do. they don't show the formula though
    http://elo.divergentinformatics.com/
     
    Last edited: Oct 10, 2012
  2. mindlube

    mindlube

    Joined:
    Oct 3, 2008
    Posts:
    993
    If anyone cares to take a look and/or use this code you are welcome to it. I think this is a valid multiplayer usage of ELO algorithm but would welcome feedback. Seems to work great. I noticed something strange however, when calculating a Tie using 0.5 for the outcome. When you tie against a better rated player, your rating goes down and their rating goes up. Doesn't seem fair. Seems like the opposite should be true. Maybe for tie games I just won't calculate new ratings :eek:

    edit: I found a bug in my code, I will add a new post below with update code and explanation.
     
    Last edited: Oct 10, 2012
  3. rpo

    rpo

    Joined:
    Oct 4, 2012
    Posts:
    1
    Sorry for resurrecting this thread. The above website is mine. You should not be seeing the lower rating go down in a tie. Your expectation is correct ... the higher one should go down and the lower one should go up. I haven't looked at your code yet but I will compare it mine and see where the differences lie. Also the way my website calculates the score is by treating each opponent vs opponent as a simultaneous individual match and then summing up the results and applying it to the score. I have a breakdown of what is happening on the results page.
     
  4. mindlube

    mindlube

    Joined:
    Oct 3, 2008
    Posts:
    993
    Hi rpo, thanks so much for the feedback confirming that-- I will post any future revisions here too.
     
  5. SebastianView

    SebastianView

    Joined:
    Oct 10, 2012
    Posts:
    2
    Hi mindlube, did you ever found the way to solve the tie issue you were having? If so can you please post the fix to the formula?

    Thanks!
     
  6. mindlube

    mindlube

    Joined:
    Oct 3, 2008
    Posts:
    993
    Hi all! Thanks for your interest. I found the bug in my code. In the Ea calculation, there is a subtraction term and the order of player vs. opponent is critical. It was just plain wrong before, and was most obviously bogus in the case of tie games. I clarified the formulas above, am attaching my updated .cs files here, and I also have done a quick spot check against http://elo.divergentinformatics.com/ and it is correct.
     

    Attached Files:

  7. SebastianView

    SebastianView

    Joined:
    Oct 10, 2012
    Posts:
    2
    Thanks for sharing and answering mindlube, you rock!
     
  8. mindlube

    mindlube

    Joined:
    Oct 3, 2008
    Posts:
    993
    No problem! Glad you are finding it useful. My code is sloppy though- I just noticed that the sum is being calculated twice. But it is at least accurate now.
     
  9. rickburgen

    rickburgen

    Joined:
    Nov 15, 2012
    Posts:
    2
    What would setting a player as provisional be for?
     
  10. janeshvarmishra

    janeshvarmishra

    Joined:
    Aug 24, 2015
    Posts:
    5
    hello have you solved all problem which arise in this elo rating system??

    i need such type or rating system fro my multiplayer game...
     
  11. MetaDOS

    MetaDOS

    Joined:
    Nov 10, 2013
    Posts:
    157
    @mindlube If we use your formula, the K-factor will not correct anymore. Ex: if there are 5 players, the first place player can win up to K * 4 Elo rating.
     
  12. nodrog007

    nodrog007

    Joined:
    Dec 15, 2013
    Posts:
    1
    Sorry for late post you need the multinomial version of the probability of win. We did this for Reiner Knizia's Samurai for multiplayer ELO.

    The formula you need is the Softmax version of the formula for expected win:

    Ea = Za / Sum(Zi, i = a, b, c, ...) for players a, b, c, ...
    where Za = 10^(B * Ra) and for standard ELO B = 1/400

    then just plug that back into your original formula for updating ELO rating's for each player:

    Ra' = Ra + K * (Sa - Ea)

    Best regards,
    Gordon