From c39463fc6972bb62997a293a4fa99f7e85522c17 Mon Sep 17 00:00:00 2001 From: James Hochadel Date: Sat, 13 Mar 2021 12:07:09 -0500 Subject: [PATCH] Initialize scores with infinity instead of arbitrarily large scores Also remove accidentally-added hash calls --- engines/alphabeta.go | 5 ++--- engines/minimax.go | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/engines/alphabeta.go b/engines/alphabeta.go index 7852307..139fc2d 100644 --- a/engines/alphabeta.go +++ b/engines/alphabeta.go @@ -26,16 +26,15 @@ func (e *AlphaBetaEngine) alphabeta(pos *chess.Position, depth int, maxPlayer bo value: e.evaluatePosition(pos), } } - pos.Hash() bestScore := &positionScore{} var comparator func(float64, float64) float64 if maxPlayer { - bestScore.value = -9999 + bestScore.value = math.Inf(-1) comparator = math.Max } else { - bestScore.value = 9999 + bestScore.value = math.Inf(1) comparator = math.Min } diff --git a/engines/minimax.go b/engines/minimax.go index 1e36bdb..050f8d5 100644 --- a/engines/minimax.go +++ b/engines/minimax.go @@ -26,16 +26,15 @@ func (e *MinimaxEngine) minimax(pos *chess.Position, depth int, maxPlayer bool) value: e.evaluatePosition(pos), } } - pos.Hash() bestScore := &positionScore{} var comparator func(float64, float64) float64 if maxPlayer { - bestScore.value = -9999 + bestScore.value = math.Inf(-1) comparator = math.Max } else { - bestScore.value = 9999 + bestScore.value = math.Inf(1) comparator = math.Min }