Skip to content

Commit

Permalink
search: sort moves by score in root of search
Browse files Browse the repository at this point in the history
  • Loading branch information
e0ff committed Nov 25, 2023
1 parent 1381d00 commit b889c41
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/search/negamax.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ func NewNegamaxSearcher(evaluator evaluation.Evaluator) NegamaxSearcher {
}

func (s NegamaxSearcher) Search(position chess.Position, depth int) ScoredMove {
moves := position.GenerateMoves(chess.LegalMoveGeneration)
bestMove := ScoredMove{}
bestScore := math.MinInt + 1

moves := position.GenerateMoves(chess.LegalMoveGeneration)
slices.SortFunc(moves, func(m1, m2 chess.Move) int {
return cmp.Compare(s.scoreMove(position, m1), s.scoreMove(position, m2))
})

for _, move := range moves {
position.MakeMove(move)

Expand Down

0 comments on commit b889c41

Please sign in to comment.