com.threerings.parlor.rating.server
Class Rating

java.lang.Object
  extended by com.threerings.parlor.rating.server.Rating
All Implemented Interfaces:
RatingCodes
Direct Known Subclasses:
RatingDelegate.PlayerRating

public class Rating
extends Object
implements RatingCodes

Encapsulates the rating/experience tuple representing a player's rating for a game, and logic for calculating rating changes.


Field Summary
 int experience
          The number of times the player's played our game.
 int rating
          The player's rating for our game.
 
Fields inherited from interface com.threerings.parlor.rating.data.RatingCodes
DEFAULT_RATING, MAXIMUM_RATING, MINIMUM_RATING
 
Constructor Summary
Rating()
           
 
Method Summary
static float computeAdjustment(float W, int opprat, Rating rating)
          Computes a ratings adjustment for the given player, using a modified version of the FIDE Chess rating system as: adjustment = K(W - We) where: K = if (experience < 20) then 64 else if (rating < 2100 and experience >= 20) then 32 else if (rating >= 2100 and rating < 2400 and experience >= 20) then 24 else 16 W = score for the game just completed, as 1.0, 0.5, and 0.0 for a win, draw, or loss, respectively.
static int computeRating(Rating[] ratings, int pidx, float W)
          Computes a player's updated rating using a modified version of the FIDE/ELO system.
 boolean isProvisional()
          Returns true if this rating is provisional (experience < 20).
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

rating

public int rating
The player's rating for our game.


experience

public int experience
The number of times the player's played our game.

Constructor Detail

Rating

public Rating()
Method Detail

computeRating

public static int computeRating(Rating[] ratings,
                                int pidx,
                                float W)
Computes a player's updated rating using a modified version of the FIDE/ELO system. The rating adjustment is computed for the player versus each opponent individually and these adjustments are summed and scaled by one over the number of opponents to create the final rating adjustment, which is then added to the player's previous rating and bounded to the rating range. Note: provisional players (those with experience of less than 20) will be treated as having, at most, the default rating when used as an opponent in calculatons for a non-provisional player.

Parameters:
ratings - the pre-match ratings of each of the opponents.
pidx - the index of the player whose rating is to be calculated.
W - the win value for the player whose rating is to be calculated, (1.0 means the player won, 0.5 means they drew, 0 means they lost).
Returns:
the player's updated rating or -1 if none of the opponents could be applicably rated against this player due to provisional/ non-provisional mismatch or lack of participation.

computeAdjustment

public static float computeAdjustment(float W,
                                      int opprat,
                                      Rating rating)
Computes a ratings adjustment for the given player, using a modified version of the FIDE Chess rating system as:
 adjustment = K(W - We)

 where:

 K = if (experience < 20) then 64
     else if (rating < 2100 and experience >= 20) then 32
     else if (rating >= 2100 and rating < 2400 and experience >= 20)
          then 24
     else 16
 W = score for the game just completed, as 1.0, 0.5, and 0.0 for a
 win, draw, or loss, respectively.
 dR = opponent's rating minus player's rating.
 We = expected score (win expectancy) as determined by:

     We = 1 / (10^(dR/400) + 1)
 

Parameters:
W - the win value the game in question (1.0 means the player won, 0.5 means they drew, 0 means they lost).
opprat - the opponent's current rating.
rating - the player's current rating.
Returns:
the adjustment to the player's rating.

isProvisional

public boolean isProvisional()
Returns true if this rating is provisional (experience < 20).


toString

public String toString()
Overrides:
toString in class Object