async def update_ratings(self): if self.result == '1-0': (white_score, black_score) = (1.0, 0.0) elif self.result == '1/2-1/2': (white_score, black_score) = (0.5, 0.5) elif self.result == '0-1': (white_score, black_score) = (0.0, 1.0) else: raise RuntimeError('game.result: unexpected result code') wr, br = self.white_rating, self.black_rating # print("ratings before updated:", wr, br) wr = gl2.rate(self.white_rating, [(white_score, br)]) br = gl2.rate(self.black_rating, [(black_score, wr)]) # print("ratings after updated:", wr, br) await self.wplayer.set_rating(self.variant, self.chess960, wr) await self.bplayer.set_rating(self.variant, self.chess960, br) self.wrdiff = int(round(wr.mu - self.white_rating.mu, 0)) self.p0 = {"e": self.wrating, "d": self.wrdiff} self.brdiff = int(round(br.mu - self.black_rating.mu, 0)) self.p1 = {"e": self.brating, "d": self.brdiff} await self.set_highscore(self.variant, self.chess960, {self.wplayer.username: int(round(wr.mu, 0))}) await self.set_highscore(self.variant, self.chess960, {self.bplayer.username: int(round(br.mu, 0))})
async def update_ratings(self): if self.result == "1-0": (white_score, black_score) = (1.0, 0.0) elif self.result == "1/2-1/2": (white_score, black_score) = (0.5, 0.5) elif self.result == "0-1": (white_score, black_score) = (0.0, 1.0) else: raise RuntimeError("game.result: unexpected result code") wr = gl2.rate(self.white_rating, [(white_score, self.black_rating)]) br = gl2.rate(self.black_rating, [(black_score, self.white_rating)]) await self.wplayer.set_rating(self.variant, self.chess960, wr) await self.bplayer.set_rating(self.variant, self.chess960, br) self.wrdiff = int(round(wr.mu - self.white_rating.mu, 0)) self.p0 = {"e": self.wrating, "d": self.wrdiff} self.brdiff = int(round(br.mu - self.black_rating.mu, 0)) self.p1 = {"e": self.brating, "d": self.brdiff} w_nb = self.wplayer.perfs[self.variant + ("960" if self.chess960 else "")]["nb"] if w_nb >= HIGHSCORE_MIN_GAMES: await self.set_highscore( self.variant, self.chess960, {self.wplayer.username: int(round(wr.mu, 0))}, ) b_nb = self.bplayer.perfs[self.variant + ("960" if self.chess960 else "")]["nb"] if b_nb >= HIGHSCORE_MIN_GAMES: await self.set_highscore( self.variant, self.chess960, {self.bplayer.username: int(round(br.mu, 0))}, )