Elo calculator

Discussion in 'Development General' started by dashdancedan, Oct 17, 2013.

  1. dashdancedan

    dashdancedan New Member

    Joined:
    Oct 17, 2013
    Messages:
    3
    Likes Received:
    0
    What elo calculator do you use in the program?
     
  2. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    chess one
     
  3. dashdancedan

    dashdancedan New Member

    Joined:
    Oct 17, 2013
    Messages:
    3
    Likes Received:
    0
    Ok but how do you incorporate it into your program? Can you give me that actual equation?
     
  4. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    http://en.wikipedia.org/wiki/Elo_rating_system

    Code (c++):
    1. QPair<int, int> MemberRating::pointChangeEstimate(int opponent_rating)
    2. {
    3.     int n = matches;
    4.  
    5.     int kfactor;
    6.     if (n <= 5) {
    7.         static const int kfactors[] = {100, 90, 80, 70, 60, 50};
    8.         kfactor = kfactors[n];
    9.     } else {
    10.         kfactor = 32;
    11.     }
    12.     double myesp = 1/(1+ pow(10., (float(opponent_rating)-rating)/400));
    13.  
    14.     /* The +0.5 is a trick to round the value instead of flooring it */
    15.     return QPair<int,int>(int((1. - myesp)*kfactor+0.5),-int(myesp*kfactor +0.5));
    16. }
    (1. - myesp) * kfactor is what you get if you win, myesp*kfactor is what you lose if you lose.

    myesp is 1/(1 + 10^((opponent_rating-rating)/400))

    kfactor is generally 32, except for first matches where it's higher.
     
  5. dashdancedan

    dashdancedan New Member

    Joined:
    Oct 17, 2013
    Messages:
    3
    Likes Received:
    0
    Cool, thanks.