Skip to content

Instantly share code, notes, and snippets.

@mattmazzola
Created November 23, 2020 02:21
Show Gist options
  • Save mattmazzola/d1045006dcb7709fc863694299dff27a to your computer and use it in GitHub Desktop.
Save mattmazzola/d1045006dcb7709fc863694299dff27a to your computer and use it in GitHub Desktop.
Create rating systems
const symmetricRatingSystem = createRatingSystem()
const playerKFactor = 32
const questionKFactor = 4
const asymmetricKFactorFn: KFactorFunctionWithPlayers = (rating, playerIndex) => {
let kFactor = playerIndex === 0
? playerKFactor
: questionKFactor
if (rating > 6000) {
kFactor = Math.ceil(kFactor / 2)
}
else if (rating > 4000) {
kFactor = Math.ceil(kFactor / 1.5)
}
return kFactor
}
const asymmetricRatingSystem = createRatingSystem(asymmetricKFactorFn)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment