dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit 81b3863f45f85c6244ec000e0155b04b9a4c1628
parent 0a001c584a712860243df89436ede27b9a6b70b8
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Wed, 14 Jun 2023 20:58:53 -0700

cleanup

Diffstat:
Mpkg/web/handlers/interceptors/chess.go | 18+++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/pkg/web/handlers/interceptors/chess.go b/pkg/web/handlers/interceptors/chess.go @@ -996,11 +996,14 @@ func standardDeviation(arr []float64) float64 { type Cp int +const CpCeiling = Cp(1000) +const CpInitial = Cp(15) + func (c Cp) ceiled() Cp { - if c > 1000 { - return 1000 - } else if c < -1000 { - return -1000 + if c > CpCeiling { + return CpCeiling + } else if c < -CpCeiling { + return -CpCeiling } return c } @@ -1047,8 +1050,9 @@ func calcWindows(allWinPercents []float64, windowSize int) (out [][]float64) { } func calcWeights(windows [][]float64) (out []float64) { - for _, w := range windows { - out = append(out, math.Min(math.Max(standardDeviation(w), 0.5), 12)) + out = make([]float64, len(windows)) + for i, w := range windows { + out[i] = math.Min(math.Max(standardDeviation(w), 0.5), 12) } return } @@ -1127,7 +1131,7 @@ func weightedMean(a [][2]float64) float64 { } func gameAccuracy(cps []int) (float64, float64) { - cps = append([]int{15}, cps...) + cps = append([]int{int(CpInitial)}, cps...) var allWinPercents []float64 for _, cp := range cps { allWinPercents = append(allWinPercents, fromCentiPawns(Cp(cp)))