Last active
November 9, 2020 18:19
-
-
Save mattmazzola/a9b278cf93f7c754bb97ec5f4aac62a2 to your computer and use it in GitHub Desktop.
Manual Usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import createRatingSystem from '@sc2/rating' | |
// Defaults to K 32, Scale 400, Base 10 | |
const ratingSystem = createRatingSystem() | |
// get two players | |
const playerA = { | |
id: 'playerA', | |
rating: 1000, | |
} | |
const playerB = { | |
id: 'playerB', | |
rating: 1200, | |
} | |
// Get expected probabilities for both players | |
const [playerAProbability, playerBProbability] = ratingSystem.getExpectedPlayerProbabilities(playerA.rating, playerB.rating) | |
const aScore = 1 | |
const bScore = 1 - aScore | |
// Get each players updated rating based on the outcome of the game using scores and probabilities from above. | |
const [nextPlayerARating, playerADiff] = ratingSystem.getNextRating(playerARating, aScore, playerAProbability) | |
const [nextPlayerBRating, playerBDiff] = ratingSystem.getNextRating(playerBRating, bScore, playerBProbability) | |
// Update player rating values | |
playerA.rating = nextPlayerARating | |
playerB.rating = nextPlayerBRating |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment