Skip to content

Commit

Permalink
search: implement aspiration windows
Browse files Browse the repository at this point in the history
  • Loading branch information
e0ff committed Dec 4, 2023
1 parent 15fc8da commit 843d09f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions internal/search/negamax.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const (

nullMovePruningReduction = 2

window = 500
window = 50

MaxDepth = 16
)
Expand Down Expand Up @@ -56,15 +56,27 @@ func (s *NegamaxSearcher) Search(position *chess.Position, depth int, print bool
s.ClearPreviousSearch()

bestMove := chess.NullMove
alpha := initialAlpha
beta := initialBeta

for d := 1; d <= depth; d++ {
start := time.Now()

score := s.doSearch(position, initialAlpha, initialBeta, d, 0, 0)
score := s.doSearch(position, alpha, beta, d, 0, 0)
if score <= alpha || score >= beta {
alpha = initialAlpha
beta = initialBeta

d--

continue
}

elapsed := time.Since(start)

bestMove = s.pvtable[0][0]
alpha = score - window
beta = score + window

if print {
nps := float64(s.nodes) / float64(elapsed.Seconds())
Expand Down

0 comments on commit 843d09f

Please sign in to comment.