Skip to content

Commit

Permalink
Foundation for rating color advantage test (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddugovic committed Nov 22, 2024
1 parent a68f539 commit 9b607a0
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rating/src/main/scala/glicko/model.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ val cluelessDeviation = 230

case class Player(
glicko: Glicko,
numberOfResults: Int,
numberOfResults: Int = 0,
lastRatingPeriodEnd: Option[Instant] = None
):
export glicko.*
Expand Down
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 9b607a0

Please sign in to comment.