skip glicko calculation when the game result is obvious

skip-glicko-obvious
Thibault Duplessis 2021-09-30 14:51:49 +02:00
parent 63ab3e23aa
commit 64ebba75c7
1 changed files with 23 additions and 15 deletions

View File

@ -114,21 +114,29 @@ final class PerfsUpdater(
) )
private def updateRatings(white: Rating, black: Rating, game: Game): Unit = { private def updateRatings(white: Rating, black: Rating, game: Game): Unit = {
val result = game.winnerColor match { // if the winner is rated more than 500 higher, leave both ratings untouched.
case Some(chess.White) => Glicko.Result.Win // this helps prevent farming and keeping deviation low by playing 1500? players
case Some(chess.Black) => Glicko.Result.Loss val isObviousResult = game.winnerColor.?? {
case None => Glicko.Result.Draw case chess.White => white.getRating - black.getRating
} case chess.Black => black.getRating - white.getRating
val results = new RatingPeriodResults() } > 500
result match { if (!isObviousResult) {
case Glicko.Result.Draw => results.addDraw(white, black) val result = game.winnerColor match {
case Glicko.Result.Win => results.addResult(white, black) case Some(chess.White) => Glicko.Result.Win
case Glicko.Result.Loss => results.addResult(black, white) case Some(chess.Black) => Glicko.Result.Loss
} case None => Glicko.Result.Draw
try { }
Glicko.system.updateRatings(results, true) val results = new RatingPeriodResults()
} catch { result match {
case e: Exception => logger.error(s"update ratings #${game.id}", e) case Glicko.Result.Draw => results.addDraw(white, black)
case Glicko.Result.Win => results.addResult(white, black)
case Glicko.Result.Loss => results.addResult(black, white)
}
try {
Glicko.system.updateRatings(results, true)
} catch {
case e: Exception => logger.error(s"update ratings #${game.id}", e)
}
} }
} }