forwardloop / glicko2s

Glicko2 sports rating system for the JVM

Website GitHub

License: MIT Maven Central Build Status Coverage Status

glicko2s

Glicko2 sport players' rating algorithm for the JVM

Usage

Maven

    <dependency>
        <groupId>com.github.forwardloop</groupId>
        <artifactId>glicko2s_2.11</artifactId>
        <version>0.9.1</version>
    </dependency>

sbt

    libraryDependencies += "com.github.forwardloop" % "glicko2s_2.11" % "0.9.1"

Java

     import static forwardloop.glicko2s.Glicko2J.newPlayerRating;
     import forwardloop.glicko2s.Glicko2;
     import scala.Tuple2;
     import java.util.Arrays;
     import java.util.List;
     
     Glicko2 playerRating = newPlayerRating();
     Glicko2 opponent1 = newPlayerRating();
     Glicko2 opponent2 = newPlayerRating();
    
     Tuple2<Glicko2, Result> g1 = new Tuple2(opponent1, Glicko2J.Win);
     Tuple2<Glicko2, Result> g2 = new Tuple2(opponent2, Glicko2J.Loss);
     Tuple2<Glicko2, Result> g3 = new Tuple2(opponent1, Glicko2J.Win);
    
     List<Tuple2<Glicko2, Result>> results = Arrays.asList(g1, g2, g3);
    
     Glicko2 newRating = Glicko2J.calculateNewRating(playerRating, results);
     
     //playerRating.toGlicko1: rating: 1500, deviation: 350.00, volatility: 0.060000
     //newRating.toGlicko1:    rating: 1600, deviation: 227.74, volatility: 0.059998

Scala

    import forwardloop.glicko2s.{Loss, Win, Glicko2}
    
    val playerRating, opponent1, opponent2 = new Glicko2
    val results = List((opponent1, Win), (opponent2, Loss), (opponent1, Win))
    val newRating = playerRating.calculateNewRating(results)
    
    //playerRating.toGlicko1: rating: 1500, deviation: 350.00, volatility: 0.060000
    //newRating.toGlicko1:    rating: 1600, deviation: 227.74, volatility: 0.059998