From: Ant Zucaro Date: Thu, 21 Dec 2017 12:59:05 +0000 (-0500) Subject: Add a KReduction class to scale points. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=673d0d59fcf2b46e0d65a421d28a20bdd01f4caf;p=xonotic%2Fxonstat.git Add a KReduction class to scale points. --- diff --git a/xonstat/glicko.py b/xonstat/glicko.py index aa002a9..ccda6d5 100644 --- a/xonstat/glicko.py +++ b/xonstat/glicko.py @@ -130,6 +130,42 @@ def rate(player, opponents, results): return new_rating +class KReduction: + """ + Scale the points gained or lost for players based on time played in the given game. + """ + def __init__(self, full_time=600, min_time=120, min_ratio=0.5): + # full time is the time played to count the player in a game + self.full_time = full_time + + # min time is the time played to count the player at all in a game + self.min_time = min_time + + # min_ratio is the ratio of the game's time to be played to be counted fully (provided + # they went past `full_time` and `min_time` above. + self.min_ratio = min_ratio + + def eval(self, my_time, match_time): + # kick out players who didn't play enough of the match + if my_time < self.min_time: + return 0.0 + + if my_time < self.min_ratio * match_time: + return 0.0 + + # scale based on time played versus what is defined as `full_time` + if my_time < self.full_time: + k = my_time / float(self.full_time) + else: + k = 1.0 + + return k + + +# Parameters for reduction of points +KREDUCTION = KReduction() + + def main(): # the example in the actual Glicko2 paper, for verification purposes pA = PlayerGlicko(1, "duel", mu=1500, phi=200)