-
-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move Elo and Glicko to a new rating module, v16.5.0
- Loading branch information
Showing
14 changed files
with
96 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
core/src/main/scala/glicko/impl/README.md → rating/src/main/scala/glicko/impl/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Loosely ported from java: https://github.com/goochjs/glicko2 | ||
|
||
The implementation is not idiomatic scala and should not be used. | ||
Use the public API instead. | ||
The implementation is not idiomatic scala and should not be used directly. | ||
Use the public API `chess.rating.glicko.GlickoCalculator` instead. |
2 changes: 1 addition & 1 deletion
2
core/src/main/scala/glicko/impl/Rating.scala → ...g/src/main/scala/glicko/impl/Rating.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package chess.glicko.impl | ||
package chess.rating.glicko.impl | ||
|
||
final class Rating( | ||
var rating: Double, | ||
|
2 changes: 1 addition & 1 deletion
2
.../scala/glicko/impl/RatingCalculator.scala → .../scala/glicko/impl/RatingCalculator.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../src/main/scala/glicko/impl/results.scala → .../src/main/scala/glicko/impl/results.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package chess.glicko.impl | ||
package chess.rating.glicko.impl | ||
|
||
trait Result: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package chess.rating | ||
package glicko | ||
|
||
import chess.{ IntRating, ByColor, Outcome } | ||
import java.time.Instant | ||
|
||
case class Glicko( | ||
rating: Double, | ||
deviation: Double, | ||
volatility: Double | ||
): | ||
def intRating: IntRating = IntRating(rating.toInt) | ||
def intDeviation = deviation.toInt | ||
def provisional = RatingProvisional(deviation >= Glicko.provisionalDeviation) | ||
def established = provisional.no | ||
def establishedIntRating = Option.when(established)(intRating) | ||
def clueless = deviation >= Glicko.cluelessDeviation | ||
def display = s"$intRating${if provisional.yes then "?" else ""}" | ||
def average(other: Glicko, weight: Float = 0.5f): Glicko = | ||
if weight >= 1 then other | ||
else if weight <= 0 then this | ||
else | ||
Glicko( | ||
rating = rating * (1 - weight) + other.rating * weight, | ||
deviation = deviation * (1 - weight) + other.deviation * weight, | ||
volatility = volatility * (1 - weight) + other.volatility * weight | ||
) | ||
override def toString = f"$intRating/$intDeviation/${volatility}%.3f" | ||
|
||
object Glicko: | ||
val provisionalDeviation = 110 | ||
val cluelessDeviation = 230 | ||
|
||
case class Player( | ||
glicko: Glicko, | ||
numberOfResults: Int, | ||
lastRatingPeriodEnd: Option[Instant] = None | ||
): | ||
export glicko.* | ||
|
||
case class Game(players: ByColor[Player], outcome: Outcome) |
8 changes: 2 additions & 6 deletions
8
core/src/main/scala/glicko/rating.scala → rating/src/main/scala/model.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
test-kit/src/test/scala/EloTest.scala → test-kit/src/test/scala/rating/EloTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
package chess | ||
package rating | ||
|
||
class EloTest extends ChessTest: | ||
|
||
|
14 changes: 7 additions & 7 deletions
14
.../test/scala/glicko/GlickoCalculator.scala → ...cala/rating/glicko/GlickoCalculator.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
...la/glicko/impl/RatingCalculatorTest.scala → ...ng/glicko/impl/RatingCalculatorTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters