Skip to content

Commit

Permalink
search: implement null move pruning
Browse files Browse the repository at this point in the history
  • Loading branch information
e0ff committed Nov 26, 2023
1 parent 0b51d1a commit 6829953
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions internal/search/negamax.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,21 @@ func (s *NegamaxSearcher) doSearch(position chess.Position, alpha int, beta int,
}
}

// null move pruning
if !inCheck && depth >= 3 && ply != 0 {
s.drawTable.Push(position.Hash())

position.MakeNullMove()
score := s.doSearch(position, -beta, -alpha, depth-2, ply+1, extensions)
position.Undo()

s.drawTable.Pop()

if score >= beta {
return beta
}
}

s.nodes++

slices.SortFunc(moves, func(m1, m2 chess.Move) int {
Expand Down

0 comments on commit 6829953

Please sign in to comment.