(float(ei.elo) - float(ej.elo)) * ep.logdistancefactor))
scorefactor_elo = 1 / (1 + math.exp(-elodiff))
- # raw ping ratios
- ping_ratio_i = self.pingfactor(pi, pj)
- ping_ratio_j = self.pingfactor(pj, pi)
-
- if ping_ratio_i > 0.5:
- if scorefactor_real > 0.5:
- log.debug("player i has the ping disadvantage and won")
- pingfactor_i = 1 + ping_ratio_i * ep.latency_trend_factor
- pingfactor_j = 1 + ping_ratio_j * ep.latency_trend_factor
- else:
- log.debug("player i has the ping disadvantage and lost")
- pingfactor_i = 1 - ping_ratio_i * ep.latency_trend_factor
- pingfactor_j = 1 - ping_ratio_j * ep.latency_trend_factor
-
- elif ping_ratio_i < 0.5:
- if scorefactor_real > 0.5:
- log.debug("player j has the ping disadvantage and lost")
- pingfactor_i = 1 - ping_ratio_i * ep.latency_trend_factor
- pingfactor_j = 1 - ping_ratio_j * ep.latency_trend_factor
- else:
- log.debug("player j has the ping disadvantage and won")
- pingfactor_i = 1 + ping_ratio_i * ep.latency_trend_factor
- pingfactor_j = 1 + ping_ratio_j * ep.latency_trend_factor
- else:
- log.debug("the pings are equal")
- pingfactor_i = pingfactor_j = 1
+ # adjust the elo prediction according to ping
+ ping_ratio = self.pingfactor(pi, pj)
+ scorefactor_ping = ep.latency_trend_factor * (0.5 - ping_ratio)
+ scorefactor_elo_adjusted = max(0, min(1, scorefactor_elo + scorefactor_ping))
# initial adjustment values, which we may modify with additional rules
- adjustmenti = (scorefactor_real - scorefactor_elo) * pingfactor_i
- adjustmentj = (scorefactor_elo - scorefactor_real) * pingfactor_j
+ adjustmenti = scorefactor_real - scorefactor_elo_adjusted
+ adjustmentj = scorefactor_elo_adjusted - scorefactor_real
# DEBUG
log.debug("(New) Player i: {0}".format(ei.player_id))
log.debug("(New) Player i's K: {0}".format(self.wip[pids[i]].k))
- log.debug("(New) Player i's pingfactor: {0}".format(pingfactor_i))
log.debug("(New) Player j: {0}".format(ej.player_id))
log.debug("(New) Player j's K: {0}".format(self.wip[pids[j]].k))
- log.debug("(New) Player j's pingfactor: {0}".format(pingfactor_j))
+ log.debug("(New) Ping ratio: {0}".format(ping_ratio))
log.debug("(New) Scorefactor real: {0}".format(scorefactor_real))
log.debug("(New) Scorefactor elo: {0}".format(scorefactor_elo))
+ log.debug("(New) Scorefactor ping: {0}".format(scorefactor_ping))
log.debug("(New) adjustment i: {0}".format(scorefactor_real - scorefactor_elo))
log.debug("(New) adjustment j: {0}".format(scorefactor_elo - scorefactor_real))
log.debug("(New) adjustment i with ping: {0}".format(adjustmenti))