def update(song_a: Song, song_b: Song, score, min_k=20): """ Updates the elos of song1 and song_b after match between song1 and song_b :param song_a: first song :param song_b: second song :param score: score of song1, 0 for loss 1 for win :param min_k: minimum weight of the match, to be scaled up by abnormal performance """ assert 0 <= score <= 1 k_a = min_k * _BONUS_BASE ** abs(song_a.calc_perf_z()) k_b = min_k * _BONUS_BASE ** abs(song_b.calc_perf_z()) print("k:", round(k_a, 1), round(k_b, 1)) exp_a = _expected(song_a.elo, song_b.elo) exp_b = 1 - exp_a song_a.elo = _elo(song_a.elo, exp_a, score, k_a) song_b.elo = _elo(song_b.elo, exp_b, 1 - score, k_b) song_a.update_recent(exp_a, score) song_b.update_recent(exp_b, 1 - score)