Add SEE to move ordering (gains 44.7 +/- 22.9)

This commit is contained in:
Mattia Giambirtone 2024-05-11 11:25:45 +02:00
parent ca3f13ef04
commit 9331729d76
1 changed files with 28 additions and 23 deletions

View File

@ -81,12 +81,11 @@ const
# higher offsets will always be placed
# first
TTMOVE_OFFSET = 700_000
MVV_LVA_OFFSET = 600_000
GOOD_SEE_OFFSET {.used.} = 500_000
KILLERS_OFFSET = 400_000
HISTORY_OFFSET = 300_000
QUIET_OFFSET = 200_000
BAD_SEE_OFFSET {.used.} = 100_000
GOOD_SEE_OFFSET = 600_000
KILLERS_OFFSET = 500_000
HISTORY_OFFSET = 400_000
QUIET_OFFSET = 300_000
BAD_SEE_OFFSET = 200_000
func computeLMRTable: array[MAX_DEPTH, array[218, int]] {.compileTime.} =
@ -187,7 +186,10 @@ proc getEstimatedMoveScore(self: SearchManager, move: Move, ply: int): int =
return KILLERS_OFFSET
if move.isTactical():
if move.isCapture():
let seeScore = self.board.position.see(move)
# We want to prioritize good captures (see > 0), but if the capture
# is bad then at least we sort it with MVVLVA
if seeScore < 0 and (move.isCapture() or move.isEnPassant()):
# Implementation of MVVLVA: Most Valuable Victim Least Valuable Aggressor.
# We prioritize moves that capture the most valuable pieces, and as a
# second goal we want to use our least valuable pieces to do so (this
@ -212,7 +214,10 @@ proc getEstimatedMoveScore(self: SearchManager, move: Move, ply: int): int =
discard # Unreachable
result += PROMOTION_MULTIPLIER * self.board.position.getPieceScore(piece, move.targetSquare)
return result + MVV_LVA_OFFSET
return result + BAD_SEE_OFFSET
else:
# If the capture is good then we just use the SEE score + the offset
return seeScore + GOOD_SEE_OFFSET
if move.isQuiet():
# History heuristic bonus