Created
November 9, 2020 18:28
-
-
Save mattmazzola/fa329d2633074b98f03e8228174424ad to your computer and use it in GitHub Desktop.
Expected 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
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