Skip to content

Commit

Permalink
Penalize captures that didn't produce a cutoff
Browse files Browse the repository at this point in the history
  • Loading branch information
eduherminio committed Jan 14, 2024
1 parent 5856b79 commit 3135900
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/Lynx/Search/NegaMax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,25 @@ private int NegaMax(int depth, int ply, int alpha, int beta, bool parentWasNullM
{
PrintMessage($"Pruning: {move} is enough");

if (!move.IsCapture())
if (move.IsCapture())
{
// 🔍 History penalty/malus
// Penalize previous captures that didn't failed high
for (int i = 0; i < visitedMovesCounter - 1; ++i)
{
var visitedMove = visitedMoves[i];
if (visitedMove.IsCapture())
{
var visitedMovePiece = visitedMove.Piece();
var visitedMoveTargetSquare = visitedMove.TargetSquare();

_historyMoves[visitedMovePiece][visitedMoveTargetSquare] = ScoreHistoryMove(
_historyMoves[visitedMovePiece][visitedMoveTargetSquare],
-EvaluationConstants.HistoryBonus[depth]);
}
}
}
else
{
// 🔍 Quiet history moves
// Doing this only in beta cutoffs (instead of when eval > alpha) was suggested by Sirius author
Expand All @@ -341,7 +359,7 @@ private int NegaMax(int depth, int ply, int alpha, int beta, bool parentWasNullM
for (int i = 0; i < visitedMovesCounter - 1; ++i)
{
var visitedMove = visitedMoves[i];
if (!visitedMove.IsCapture()) // TODO: Penalize only quiets?
//if (!visitedMove.IsCapture()) // TODO: Penalize only quiets?
{
var visitedMovePiece = visitedMove.Piece();
var visitedMoveTargetSquare = visitedMove.TargetSquare();
Expand Down

0 comments on commit 3135900

Please sign in to comment.