MCPcopy Create free account
hub / github.com/FloatTech/ZeroBot-Plugin / calculateNewRate

Function calculateNewRate

plugin/chess/elo.go:8–15  ·  view source on GitHub ↗

calculateNewRate calculate new rate of the player

(whiteRate, blackRate int, whiteScore, blackScore float64)

Source from the content-addressed store, hash-verified

6
7// calculateNewRate calculate new rate of the player
8func calculateNewRate(whiteRate, blackRate int, whiteScore, blackScore float64) (int, int) {
9 k := getKFactor(whiteRate, blackRate)
10 exceptionWhite := calculateException(whiteRate, blackRate)
11 exceptionBlack := calculateException(blackRate, whiteRate)
12 whiteRate = calculateRate(whiteRate, whiteScore, exceptionWhite, k)
13 blackRate = calculateRate(blackRate, blackScore, exceptionBlack, k)
14 return whiteRate, blackRate
15}
16
17func calculateException(rate int, opponentRate int) float64 {
18 return 1.0 / (1.0 + math.Pow(10.0, float64(opponentRate-rate)/400.0))

Callers 2

updateELORateFunction · 0.85
TestCalculateNewRateFunction · 0.85

Calls 3

getKFactorFunction · 0.85
calculateExceptionFunction · 0.85
calculateRateFunction · 0.85

Tested by 1

TestCalculateNewRateFunction · 0.68