halve human rating diff in a match against a bot
This commit is contained in:
parent
c95a010cad
commit
0a351973bb
|
@ -38,6 +38,12 @@ case class Glicko(
|
|||
volatility = volatility atMost Glicko.maxVolatility
|
||||
)
|
||||
|
||||
def average(other: Glicko) = Glicko(
|
||||
rating = (rating + other.rating) / 2,
|
||||
deviation = (deviation + other.deviation) / 2,
|
||||
volatility = (volatility + other.volatility) / 2
|
||||
)
|
||||
|
||||
override def toString = s"$intRating $intDeviation"
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,10 @@ case class Perf(
|
|||
add(Glicko.default, date)
|
||||
}
|
||||
|
||||
def averageGlicko(other: Perf) = copy(
|
||||
glicko = glicko average other.glicko
|
||||
)
|
||||
|
||||
def refund(points: Int): Perf = {
|
||||
val newGlicko = glicko refund points
|
||||
copy(
|
||||
|
|
|
@ -57,8 +57,8 @@ final class PerfsUpdater(
|
|||
}
|
||||
case _ =>
|
||||
}
|
||||
val perfsW = mkPerfs(ratingsW, white.perfs, game)
|
||||
val perfsB = mkPerfs(ratingsB, black.perfs, game)
|
||||
val perfsW = mkPerfs(ratingsW, white -> black, game)
|
||||
val perfsB = mkPerfs(ratingsB, black -> white, game)
|
||||
def intRatingLens(perfs: Perfs) = mainPerf(perfs).glicko.intRating
|
||||
val ratingDiffs = Color.Map(
|
||||
intRatingLens(perfsW) - intRatingLens(white.perfs),
|
||||
|
@ -124,16 +124,24 @@ final class PerfsUpdater(
|
|||
}
|
||||
try {
|
||||
system.updateRatings(results)
|
||||
} catch {
|
||||
}
|
||||
catch {
|
||||
case e: Exception => logger.error("update ratings", e)
|
||||
}
|
||||
}
|
||||
|
||||
private def mkPerfs(ratings: Ratings, perfs: Perfs, game: Game): Perfs = {
|
||||
private def mkPerfs(ratings: Ratings, users: (User, User), game: Game): Perfs = users match {
|
||||
case (player, opponent) =>
|
||||
val perfs = player.perfs
|
||||
val speed = game.speed
|
||||
val isStd = game.ratingVariant.standard
|
||||
val isHumanVsMachine = player.noBot && opponent.isBot
|
||||
def addRatingIf(cond: Boolean, perf: Perf, rating: Rating) =
|
||||
if (cond) perf.addOrReset(_.round.error.glicko, s"game ${game.id}")(rating, game.movedAt)
|
||||
if (cond) {
|
||||
val p = perf.addOrReset(_.round.error.glicko, s"game ${game.id}")(rating, game.movedAt)
|
||||
if (isHumanVsMachine) perf averageGlicko p // halve rating diffs for human
|
||||
else p
|
||||
}
|
||||
else perf
|
||||
val perfs1 = perfs.copy(
|
||||
chess960 = addRatingIf(game.ratingVariant.chess960, perfs.chess960, ratings.chess960),
|
||||
|
|
Loading…
Reference in a new issue