Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement World Rankings #300

Open
lemonpole opened this issue Dec 2, 2024 · 0 comments
Open

Implement World Rankings #300

lemonpole opened this issue Dec 2, 2024 · 0 comments
Assignees
Milestone

Comments

@lemonpole
Copy link
Member

lemonpole commented Dec 2, 2024

Might have to just use ELO. There's a lot of different ranking systems like HLTV, Valve, etc., each with their own algorithms.


function calculateExpectedScore(ratingA: number, ratingB: number): number {
  return 1 / (1 + Math.pow(10, (ratingB - ratingA) / 400));
}

function calculateNewRating(rating: number, expectedScore: number, actualScore: number, kFactor: number): number {
  return rating + kFactor * (actualScore - expectedScore);
}

// Example usage:
let player1Rating = 1500;
let player2Rating = 1600;
let kFactor = 32;

let expectedScore1 = calculateExpectedScore(player1Rating, player2Rating);
let expectedScore2 = calculateExpectedScore(player2Rating, player1Rating);

// Assume player 1 wins
let player1NewRating = calculateNewRating(player1Rating, expectedScore1, 1, kFactor);
let player2NewRating = calculateNewRating(player2Rating, expectedScore2, 0, kFactor);

console.log("Player 1 new rating:", player1NewRating);
console.log("Player 2 new rating:", player2NewRating);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

1 participant