Skip to content

Commit

Permalink
[TGB-42] Fixed elo delta and sigma calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
Divy1211 committed Jan 4, 2023
1 parent 8229841 commit a809284
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/abstract_commands/matches/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,16 @@ export async function report(
}

let teamRatings = teamStats.map((team: PlayerStats[]) => team.map(
(stats: PlayerStats) => new Rating(stats.rating, stats.sigma + 5 * stats.streak)
(stats: PlayerStats) => new Rating(stats.rating, stats.sigma + 5 * Math.abs(stats.streak))
));
teamRatings = rate(teamRatings);
const idx = match.winningTeam === 2 ? 1 : 0;
const newPlayerRatings = [...teamRatings[idx], ...teamRatings[1-idx]];
const playerStats = [...teamStats[idx], ...teamStats[1-idx]];

const newPlayerRatings = [...teamRatings[0], ...teamRatings[1]];
const playerStats = [...teamStats[0], ...teamStats[1]];

for (const [player2, newRating, stats] of zip(ensure(match.players), newPlayerRatings, playerStats)) {
player2.ratingDelta = Math.floor(newRating.mu-stats.rating);
stats.rating += player2.ratingDelta;
for (const [player, newRating, stats] of zip(ensure(match.players), newPlayerRatings, playerStats)) {
player.ratingDelta = Math.floor(newRating.mu-stats.rating);
stats.rating += player.ratingDelta;
// sigma should never be lower than 25
stats.sigma = Math.max(25, Math.floor(newRating.sigma));
}
Expand Down

0 comments on commit a809284

Please sign in to comment.