Glicko2 (improved ELO) sports players rating system for the JVM
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
project
src
.travis.yml
LICENSE.md
README.md
build.sbt
sbt

README.md

License: MIT Maven Central Build Status Coverage Status

glicko2s

Glicko2 sport players' rating algorithm for the JVM. Details on ELO and Glicko systems can be found at ELO Wikipedia, Glicko Wikipedia, or Glicko-2 Example. This project is used for computing ELO ratings in the squash players ranking system, for example in Waterfront and Fareham Leisure Centre leagues.

Build

Maven

    <dependency>
        <groupId>com.github.forwardloop</groupId>
        <artifactId>glicko2s_2.12</artifactId>
        <version>0.9.4</version>
    </dependency>

Gradle

    compile 'com.github.forwardloop:glicko2s_2.12:0.9.4'

sbt

    libraryDependencies += "com.github.forwardloop" %% "glicko2s" % "0.9.4"

Usage

Compute new rating for a player based on a sequence of match results with other players:

Java

     import static forwardloop.glicko2s.Glicko2J.newPlayerRating;
     import forwardloop.glicko2s.Glicko2;
     import scala.Tuple2;
     import java.util.Arrays;
     import java.util.List;
     Glicko2 player = newPlayerRating();
     Glicko2 opponent1 = newPlayerRating();
     Glicko2 opponent2 = newPlayerRating();
    
     Tuple2<Glicko2, Result> match1 = new Tuple2(opponent1, Glicko2J.Win);
     Tuple2<Glicko2, Result> match2 = new Tuple2(opponent2, Glicko2J.Loss);
     Tuple2<Glicko2, Result> match3 = new Tuple2(opponent1, Glicko2J.Win);
    
     List<Tuple2<Glicko2, Result>> results = Arrays.asList(match1, match2, match3);
     Glicko2 newRating = Glicko2J.calculateNewRating(player, results);

Scala

The project is cross-compiled for Scala 2.11 and 2.12.

    import forwardloop.glicko2s.{Loss, Win, Glicko2}
    
    val player, opponent1, opponent2 = new Glicko2
    val results = Seq(
         (opponent1, Win), 
         (opponent2, Loss), 
         (opponent1, Win))
    val newRating = player.calculateNewRating(results)

The rating, rating deviation and volatility parameters will change as follows:

    //player.toGlicko1:    rating: 1500, deviation: 350.00, volatility: 0.060000
    //newRating.toGlicko1: rating: 1600, deviation: 227.74, volatility: 0.059998

Customise

Weights of results

The simple implementation of the EloResult trait provided allows three outcomes: win, draw or loss with weights 1.0, 0.5, 0.0, respectively. This can be fine tuned to differentiate between outcomes like 3:0 and 3:2, to better reflect true players' level in ELO computations. An example implementation for racquet sports can be found here