calculateNewRate calculate new rate of the player
(whiteRate, blackRate int, whiteScore, blackScore float64)
| 6 | |
| 7 | // calculateNewRate calculate new rate of the player |
| 8 | func 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 | |
| 17 | func calculateException(rate int, opponentRate int) float64 { |
| 18 | return 1.0 / (1.0 + math.Pow(10.0, float64(opponentRate-rate)/400.0)) |