return new_rating
-class KReduction:
+class KReduction(object):
"""
Scale the points gained or lost for players based on time played in the given game.
"""
# the list of results for those games in the ranking period
self.results = []
+ def __repr__(self):
+ return ("<GlickoWIP({0.pg}, k={0.k_factors}, ping={0.ping_factors}, "
+ "opponents={0.opponents}, results={0.results})>".format(self))
+
class GlickoProcessor(object):
"""
Model initialization and mapping.
"""
-from sqlalchemy import MetaData
+from sqlalchemy import MetaData, Numeric
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import scoped_session, sessionmaker, mapper
player_glickos_base_table = metadata.tables['player_glickos_base']
player_glickos_current_table = metadata.tables['player_glickos_current']
+ # explicit floats instead of decimals in certain tables
+ for table in [player_glickos_base_table, player_glickos_current_table]:
+ for column in table.columns.values():
+ if isinstance(column.type, Numeric):
+ column.type.asdecimal = False
+
# Map the tables and the objects together
mapper(PlayerAchievement, achievements_table)
mapper(Achievement, cd_achievement_table)
# Glicko Constants
# the default initial rating value
-MU = 1500
+MU = 1500.0
# the default ratings deviation value
-PHI = 350
+PHI = 350.0
# the default volatility value
SIGMA = 0.06
self.player_id = player_id
self.game_type_cd = game_type_cd
self.category = category
- self.mu = mu
+ self.mu = float(mu)
self.phi = phi
self.sigma = sigma
player_id=self.player_id,
game_type_cd=self.game_type_cd,
category=self.category,
- mu=(self.mu - MU) / GLICKO2_SCALE,
- phi=self.phi / GLICKO2_SCALE,
+ mu=(float(self.mu) - MU)/GLICKO2_SCALE,
+ phi=self.phi/GLICKO2_SCALE,
sigma=self.sigma
)
sigma=self.sigma
)
+ def __repr__(self):
+ return ("<PlayerGlicko({0.player_id}, {0.game_type_cd}, {0.category}, "
+ "{0.mu}, {0.phi}, {0.sigma})>".format(self))
+
class PlayerGlickoBase(PlayerGlicko):
"""