From 274773e32f014cc0c69ce99b973cd4abc41cde05 Mon Sep 17 00:00:00 2001 From: Daniel Dugovic Date: Fri, 22 Nov 2024 07:52:25 -0600 Subject: [PATCH] Test ratings round to the nearest whole number --- .../rating/glicko/GlickoCalculatorTest.scala | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/test-kit/src/test/scala/rating/glicko/GlickoCalculatorTest.scala b/test-kit/src/test/scala/rating/glicko/GlickoCalculatorTest.scala index 99ca9d11a..a8be10a51 100644 --- a/test-kit/src/test/scala/rating/glicko/GlickoCalculatorTest.scala +++ b/test-kit/src/test/scala/rating/glicko/GlickoCalculatorTest.scala @@ -24,28 +24,28 @@ class GlickoCalculatorTest extends ScalaCheckSuite with chess.MunitExtensions: ) test("default deviation: white wins"): val (w, b) = computeGame(players, Outcome.white) - assertCloseTo(w.rating, 1741d, 1d) - assertCloseTo(b.rating, 1258d, 1d) - assertCloseTo(w.deviation, 396d, 1d) - assertCloseTo(b.deviation, 396d, 1d) - assertCloseTo(w.volatility, 0.0899983, 0.00000001d) - assertCloseTo(b.volatility, 0.0899983, 0.0000001d) + assertCloseTo(w.rating, 1662d, 0.5d) + assertCloseTo(b.rating, 1338d, 0.5d) + assertCloseTo(w.deviation, 290d, 0.5d) + assertCloseTo(b.deviation, 290d, 0.5d) + assertCloseTo(w.volatility, 0.0599993d, 0.0000001d) + assertCloseTo(b.volatility, 0.0599993d, 0.0000001d) test("default deviation: black wins"): val (w, b) = computeGame(players, Outcome.black) - assertCloseTo(w.rating, 1258d, 1d) - assertCloseTo(b.rating, 1741d, 1d) - assertCloseTo(w.deviation, 396d, 1d) - assertCloseTo(b.deviation, 396d, 1d) - assertCloseTo(w.volatility, 0.0899983, 0.00000001d) - assertCloseTo(b.volatility, 0.0899983, 0.0000001d) + assertCloseTo(w.rating, 1338d, 0.5d) + assertCloseTo(b.rating, 1662d, 0.5d) + assertCloseTo(w.deviation, 290d, 0.5d) + assertCloseTo(b.deviation, 290d, 0.5d) + assertCloseTo(w.volatility, 0.0599993d, 0.0000001d) + assertCloseTo(b.volatility, 0.0599993d, 0.0000001d) test("default deviation: draw"): val (w, b) = computeGame(players, Outcome.draw) - assertCloseTo(w.rating, 1500d, 1d) - assertCloseTo(b.rating, 1500d, 1d) - assertCloseTo(w.deviation, 396d, 1d) - assertCloseTo(b.deviation, 396d, 1d) - assertCloseTo(w.volatility, 0.0899954, 0.0000001d) - assertCloseTo(b.volatility, 0.0899954, 0.0000001d) + assertCloseTo(w.rating, 1500d, 0.5d) + assertCloseTo(b.rating, 1500d, 0.5d) + assertCloseTo(w.deviation, 290d, 0.5d) + assertCloseTo(b.deviation, 290d, 0.5d) + assertCloseTo(w.volatility, 0.0599977d, 0.0000001d) + assertCloseTo(b.volatility, 0.0599977d, 0.0000001d) } { @@ -63,25 +63,25 @@ class GlickoCalculatorTest extends ScalaCheckSuite with chess.MunitExtensions: ) test("mixed ratings and deviations: white wins"): val (w, b) = computeGame(players, Outcome.white) - assertCloseTo(w.rating, 1422d, 1d) - assertCloseTo(b.rating, 1506d, 1d) - assertCloseTo(w.deviation, 77d, 1d) - assertCloseTo(b.deviation, 105d, 1d) + assertCloseTo(w.rating, 1423d, 0.5d) + assertCloseTo(b.rating, 1506d, 0.5d) + assertCloseTo(w.deviation, 77d, 0.5d) + assertCloseTo(b.deviation, 106d, 0.5d) assertCloseTo(w.volatility, 0.06, 0.00001d) assertCloseTo(b.volatility, 0.065, 0.00001d) test("mixed ratings and deviations: black wins"): val (w, b) = computeGame(players, Outcome.black) - assertCloseTo(w.rating, 1389d, 1d) - assertCloseTo(b.rating, 1568d, 1d) - assertCloseTo(w.deviation, 78d, 1d) - assertCloseTo(b.deviation, 105d, 1d) + assertCloseTo(w.rating, 1390d, 0.5d) + assertCloseTo(b.rating, 1569d, 0.5d) + assertCloseTo(w.deviation, 77d, 0.5d) + assertCloseTo(b.deviation, 106d, 0.5d) assertCloseTo(w.volatility, 0.06, 0.00001d) assertCloseTo(b.volatility, 0.065, 0.00001d) test("mixed ratings and deviations: draw"): val (w, b) = computeGame(players, Outcome.draw) - assertCloseTo(w.rating, 1406d, 1d) - assertCloseTo(b.rating, 1537d, 1d) - assertCloseTo(w.deviation, 78d, 1d) + assertCloseTo(w.rating, 1406d, 0.5d) + assertCloseTo(b.rating, 1538d, 0.5d) + assertCloseTo(w.deviation, 77d, 0.5d) assertCloseTo(b.deviation, 105.87d, 0.01d) assertCloseTo(w.volatility, 0.06, 0.00001d) assertCloseTo(b.volatility, 0.065, 0.00001d)