- Reduce tau value, as suggested in gecko2 paper
authorunc0rr
Sun, 15 Nov 2015 21:57:38 +0300
changeset 11390 36e1bbb6ecea
parent 11389 c93f204a5a00
child 11391 bc9650ec9b20
- Reduce tau value, as suggested in gecko2 paper - Also store games number per epoch
gameServer/OfficialServer/Glicko2.hs
gameServer/OfficialServer/updateRating.hs
--- a/gameServer/OfficialServer/Glicko2.hs	Sun Nov 15 10:22:42 2015 -0500
+++ b/gameServer/OfficialServer/Glicko2.hs	Sun Nov 15 21:57:38 2015 +0300
@@ -15,7 +15,7 @@
     }
 
 τ, ε :: Double
-τ = 0.3
+τ = 0.2
 ε = 0.000001
 
 g_φ :: Double -> Double
@@ -35,13 +35,13 @@
         g_φᵢ = g_φ φᵢ
 
 
-calcNewRating :: RatingData -> [GameData] -> RatingData
-calcNewRating oldRating [] = RatingData (ratingValue oldRating) (173.7178 * sqrt (φ ^ 2 + σ ^ 2)) σ
+calcNewRating :: RatingData -> [GameData] -> (Int, RatingData)
+calcNewRating oldRating [] = (0, RatingData (ratingValue oldRating) (173.7178 * sqrt (φ ^ 2 + σ ^ 2)) σ)
     where
         φ = rD oldRating / 173.7178
         σ = volatility oldRating
 
-calcNewRating oldRating games = RatingData (173.7178 * μ' + 1500) (173.7178 * sqrt φ'sqr) σ'
+calcNewRating oldRating games = (length games, RatingData (173.7178 * μ' + 1500) (173.7178 * sqrt φ'sqr) σ')
     where
         _Es = map (calcE oldRating) games
         υ = 1 / sum (map υ_p _Es)
--- a/gameServer/OfficialServer/updateRating.hs	Sun Nov 15 10:22:42 2015 -0500
+++ b/gameServer/OfficialServer/updateRating.hs	Sun Nov 15 21:57:38 2015 +0300
@@ -37,14 +37,13 @@
         \     LEFT OUTER JOIN rating_values as vo ON (vo.epoch = e.epoch AND vo.userid = o.userid) \
         \ GROUP BY p.userid, p.gameid, p.place \
         \ ORDER BY p.userid"
-insertNewRatings = "INSERT INTO rating_values (userid, epoch, rating, rd, volatility) VALUES (?, ?, ?, ?, ?)"
+insertNewRatings = "INSERT INTO rating_values (userid, epoch, rating, rd, volatility, games) VALUES (?, ?, ?, ?, ?, ?)"
 insertNewEpoch = "INSERT INTO rating_epochs (epoch, todatetime) VALUES (?, ?)"
 
 mergeRatingData :: Map.Map Int (RatingData, [GameData]) -> [(Int, (RatingData, [GameData]))] -> Map.Map Int (RatingData, [GameData])
-mergeRatingData m s = foldr (unc0rry (Map.insertWith mf)) m s
+mergeRatingData m s = foldr (uncurry (Map.insertWith mf)) m s
     where
         mf (rd, gds) (_, gds2) = (rd, gds ++ gds2)
-        unc0rry f (a, b) c = f a b c
 
 calculateRatings dbConn = do
     [(epochNum :: Int, fromDate :: UTCTime, toDate :: UTCTime)] <- query_ dbConn queryEpochDates
@@ -55,7 +54,7 @@
     execute dbConn insertNewEpoch (epochNum + 1, toDate)
     return ()
     where
-        toInsert e (i, RatingData r rd v) = (i, e + 1, r, rd, v)
+        toInsert e (i, (g, RatingData r rd v)) = (i, e + 1, r, rd, v, g)
         getNewRating (a, d) = (a, uncurry calcNewRating d)
         convPlace :: Int -> Double
         convPlace 0 = 0.5