diff --git a/rating/src/main/scala/glicko/model.scala b/rating/src/main/scala/glicko/model.scala index 154942154..1237ffb33 100644 --- a/rating/src/main/scala/glicko/model.scala +++ b/rating/src/main/scala/glicko/model.scala @@ -34,7 +34,7 @@ val cluelessDeviation = 230 case class Player( glicko: Glicko, - numberOfResults: Int, + numberOfResults: Int = 0, lastRatingPeriodEnd: Option[Instant] = None ): export glicko.* diff --git a/test-kit/src/test/scala/rating/glicko/GlickoCalculatorWithColorAdvantageTest.scala b/test-kit/src/test/scala/rating/glicko/GlickoCalculatorWithColorAdvantageTest.scala new file mode 100644 index 000000000..c63b271c8 --- /dev/null +++ b/test-kit/src/test/scala/rating/glicko/GlickoCalculatorWithColorAdvantageTest.scala @@ -0,0 +1,40 @@ +package chess +package rating +package glicko + +class GlickoCalculatorWithColorAdvantageTest extends ChessTest: + + import Outcome.* + + private def ratingDiff(r: Int, opRating: Int, outcome: Outcome, expected: Int)(using + munit.Location + ) = + val player = Player(Glicko(r, 1d, 1d)) + val opponent = Player(Glicko(opRating, 1d, 1d)) + val game = Game(ByColor(player, opponent), outcome) + // TODO: calculator with color advantage + val calculator = GlickoCalculator() + calculator.computeGame(game) + + test("new rating calculation over one game"): + ratingDiff(1500, 1500, white, 20) + ratingDiff(1500, 1500, black, -20) + ratingDiff(1500, 1500, draw, 0) + ratingDiff(1500, 1900, white, 37) + ratingDiff(1500, 1900, black, -3) + ratingDiff(1500, 1900, draw, 17) + ratingDiff(1500, 2900, white, 37) + ratingDiff(1500, 2900, black, -3) + ratingDiff(1500, 2900, draw, 17) + ratingDiff(1500, 1600, white, 26) + ratingDiff(1500, 1600, black, -14) + ratingDiff(1500, 1600, draw, 6) + ratingDiff(2000, 1600, white, 3) + ratingDiff(2000, 1600, black, -37) + ratingDiff(2000, 1600, draw, -17) + ratingDiff(2000, 1000, white, 3) + ratingDiff(2000, 1000, black, -37) + ratingDiff(2000, 1000, draw, -17) + ratingDiff(2000, 1900, white, 14) + ratingDiff(2000, 1900, black, -26) + ratingDiff(2000, 1900, draw, -6)