Skip to content

Commit

Permalink
search: change nodes per second to float64
Browse files Browse the repository at this point in the history
  • Loading branch information
e0ff committed Nov 26, 2023
1 parent 3d78df7 commit 402c2a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/rosaline/interfaces/uci.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 3 additions & 4 deletions internal/search/negamax.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type SearchResults struct {
Depth int
Nodes int
Time time.Duration
NPS int
NPS float64
}

type NegamaxSearcher struct {
Expand All @@ -35,7 +35,6 @@ type NegamaxSearcher struct {
stop bool

nodes int
nps int
}

func NewNegamaxSearcher(evaluator evaluation.Evaluator) NegamaxSearcher {
Expand Down Expand Up @@ -74,15 +73,15 @@ 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,
Score: bestScore,
Depth: depth,
Nodes: s.nodes,
Time: elapsed,
NPS: s.nps,
NPS: nps,
}
}

Expand Down

0 comments on commit 402c2a5

Please sign in to comment.