From 402c2a5ab171d327c9a9ef43ea9f88480d46806b Mon Sep 17 00:00:00 2001 From: Jeremy Hertel Date: Sat, 25 Nov 2023 19:16:06 -0600 Subject: [PATCH] search: change nodes per second to float64 --- cmd/rosaline/interfaces/uci.go | 2 +- internal/search/negamax.go | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cmd/rosaline/interfaces/uci.go b/cmd/rosaline/interfaces/uci.go index 57e0b91..1801b95 100644 --- a/cmd/rosaline/interfaces/uci.go +++ b/cmd/rosaline/interfaces/uci.go @@ -68,7 +68,7 @@ loop: bestScore = results.Score } - fmt.Printf("info depth %d score cp %d nodes %d nps %d time %d\n", depth, results.Score, results.Nodes, results.NPS, results.Time.Milliseconds()) + fmt.Printf("info depth %d score cp %d nodes %d nps %f time %d\n", depth, results.Score, results.Nodes, results.NPS, results.Time.Milliseconds()) } position.MakeMove(bestMove) diff --git a/internal/search/negamax.go b/internal/search/negamax.go index 9c55b78..20979f0 100644 --- a/internal/search/negamax.go +++ b/internal/search/negamax.go @@ -22,7 +22,7 @@ type SearchResults struct { Depth int Nodes int Time time.Duration - NPS int + NPS float64 } type NegamaxSearcher struct { @@ -35,7 +35,6 @@ type NegamaxSearcher struct { stop bool nodes int - nps int } func NewNegamaxSearcher(evaluator evaluation.Evaluator) NegamaxSearcher { @@ -74,7 +73,7 @@ func (s NegamaxSearcher) Search(position chess.Position, depth int) SearchResult } elapsed := time.Since(start) - s.nps = int(int64(s.nodes) / elapsed.Milliseconds()) + nps := float64(s.nodes) / float64(elapsed.Milliseconds()) return SearchResults{ BestMove: bestMove, @@ -82,7 +81,7 @@ func (s NegamaxSearcher) Search(position chess.Position, depth int) SearchResult Depth: depth, Nodes: s.nodes, Time: elapsed, - NPS: s.nps, + NPS: nps, } }