commit 6a353525aeb2e2a17dcfcfd9a1cc262be112ed62
parent fe57f731ca277b950fffcf943519e45b5c10a54b
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Wed, 14 Jun 2023 13:23:26 -0700
keep track of best move
Diffstat:
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/pkg/web/handlers/interceptors/chess.go b/pkg/web/handlers/interceptors/chess.go
@@ -840,9 +840,10 @@ func CalcAdvantage(position *chess.Position) (string, string, string, string) {
}
type Score struct {
- Move string
- CP int
- Mate int
+ Move string
+ BestMove string
+ CP int
+ Mate int
}
type AnalyseResult struct {
@@ -905,8 +906,9 @@ func AnalyseGame(pgn string, t int64) (out AnalyseResult, err error) {
}
mov := g.MoveHistory()[idx-1].Move
moveStr := chess.AlgebraicNotation{}.Encode(positions[idx-1], mov)
+ bestMoveStr := chess.AlgebraicNotation{}.Encode(position, res.BestMove)
cps = append(cps, cp)
- scores = append(scores, Score{Move: moveStr, CP: cp, Mate: mate})
+ scores = append(scores, Score{Move: moveStr, BestMove: bestMoveStr, CP: cp, Mate: mate})
//fmt.Printf("%d: %d/%d %d %d\n", idx/2, idx, len(positions), idx%2, cp)
}