]> de.git.xonotic.org Git - xonotic/xonstat.git/blobdiff - xonstat/elo.py
dos2unix file conversions for everything
[xonotic/xonstat.git] / xonstat / elo.py
old mode 100755 (executable)
new mode 100644 (file)
index 9d1d467..19bcfba
@@ -1,46 +1,46 @@
-import sys\r
-import math\r
-import random\r
-\r
-class EloParms:\r
-    def __init__(self, global_K = 15, initial = 100, floor = 100, logdistancefactor = math.log(10)/float(400), maxlogdistance = math.log(10)):\r
-        self.global_K = global_K\r
-        self.initial = initial\r
-        self.floor = floor\r
-        self.logdistancefactor = logdistancefactor\r
-        self.maxlogdistance = maxlogdistance\r
-\r
-\r
-class KReduction:\r
-    def __init__(self, fulltime, mintime, minratio, games_min, games_max, games_factor):\r
-        self.fulltime = fulltime\r
-        self.mintime = mintime\r
-        self.minratio = minratio\r
-        self.games_min = games_min\r
-        self.games_max = games_max\r
-        self.games_factor = games_factor\r
-\r
-    def eval(self, mygames, mytime, matchtime):\r
-        if mytime < self.mintime:\r
-            return 0\r
-        if mytime < self.minratio * matchtime:\r
-            return 0\r
-        if mytime < self.fulltime:\r
-            k = mytime / float(self.fulltime)\r
-        else:\r
-            k = 1.0\r
-        if mygames >= self.games_max:\r
-            k *= self.games_factor\r
-        elif mygames > self.games_min:\r
-            k *= 1.0 - (1.0 - self.games_factor) * (mygames - self.games_min) / float(self.games_max - self.games_min)\r
-        return k\r
-\r
-\r
-# parameters for K reduction\r
-# this may be touched even if the DB already exists\r
-KREDUCTION = KReduction(600, 120, 0.5, 0, 32, 0.2)\r
-\r
-# parameters for chess elo\r
-# only global_K may be touched even if the DB already exists\r
-# we start at K=200, and fall to K=40 over the first 20 games\r
-ELOPARMS = EloParms(global_K = 200)\r
+import sys
+import math
+import random
+
+class EloParms:
+    def __init__(self, global_K = 15, initial = 100, floor = 100, logdistancefactor = math.log(10)/float(400), maxlogdistance = math.log(10)):
+        self.global_K = global_K
+        self.initial = initial
+        self.floor = floor
+        self.logdistancefactor = logdistancefactor
+        self.maxlogdistance = maxlogdistance
+
+
+class KReduction:
+    def __init__(self, fulltime, mintime, minratio, games_min, games_max, games_factor):
+        self.fulltime = fulltime
+        self.mintime = mintime
+        self.minratio = minratio
+        self.games_min = games_min
+        self.games_max = games_max
+        self.games_factor = games_factor
+
+    def eval(self, mygames, mytime, matchtime):
+        if mytime < self.mintime:
+            return 0
+        if mytime < self.minratio * matchtime:
+            return 0
+        if mytime < self.fulltime:
+            k = mytime / float(self.fulltime)
+        else:
+            k = 1.0
+        if mygames >= self.games_max:
+            k *= self.games_factor
+        elif mygames > self.games_min:
+            k *= 1.0 - (1.0 - self.games_factor) * (mygames - self.games_min) / float(self.games_max - self.games_min)
+        return k
+
+
+# parameters for K reduction
+# this may be touched even if the DB already exists
+KREDUCTION = KReduction(600, 120, 0.5, 0, 32, 0.2)
+
+# parameters for chess elo
+# only global_K may be touched even if the DB already exists
+# we start at K=200, and fall to K=40 over the first 20 games
+ELOPARMS = EloParms(global_K = 200)