Skip to content

Instantly share code, notes, and snippets.

@mattmazzola
Created November 9, 2020 18:28
Show Gist options
  • Save mattmazzola/fa329d2633074b98f03e8228174424ad to your computer and use it in GitHub Desktop.
Save mattmazzola/fa329d2633074b98f03e8228174424ad to your computer and use it in GitHub Desktop.
Expected Usage
function createNextRatingsFn(
getExpectedPlayerProbabilities: ExpectedProbabilitiesFn,
getNextARating: NextRatingFn,
getNextBRating: NextRatingFn
): NextRatingsFn {
const nextRatingsFn = (playerARating: number, playerBRating: number, playerAScore: number) => {
const [expectedPlayerAProbability, expectedPlayerBProbability] = getExpectedPlayerProbabilities(playerARating, playerBRating)
const aProbability = playerAScore
const bProbability = 1 - playerAScore
const [nextPlayerARating, playerARatingDiff] = getNextARating(playerARating, aProbability, expectedPlayerAProbability)
const [nextPlayerBRating, playerBRatingDiff] = getNextBRating(playerBRating, bProbability, expectedPlayerBProbability)
return {
playerAProbability: expectedPlayerAProbability,
playerBProbability: expectedPlayerBProbability,
nextPlayerARating,
playerARatingDiff,
nextPlayerBRating,
playerBRatingDiff,
}
}
return nextRatingsFn
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment