Skip to content

Commit

Permalink
Add bonus for KQR forks
Browse files Browse the repository at this point in the history
  • Loading branch information
eduherminio committed Nov 22, 2024
1 parent eaec907 commit 735f4ba
Show file tree
Hide file tree
Showing 3 changed files with 2,992 additions and 2,970 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,9 @@ static partial class EvaluationParams
/// </summary>
public const int PieceAttackedByPawnPenalty = -2162735;

/// <summary>
/// <see cref="Utils.Pack(55, 94)"/>
/// </summary>
public const int KnightForkBounus = 6160439;

}
14 changes: 14 additions & 0 deletions src/Lynx/Model/Position.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Buffers;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Text;

Expand Down Expand Up @@ -732,6 +733,19 @@ private int KnightAdditionalEvaluation(int squareIndex, int pieceSide, int oppos

packedBonus += CheckBonus[(int)Piece.N] * checks;

// Forks
var offset = Utils.PieceOffset(pieceSide);
var majorPieces = PieceBitBoards[(int)Piece.k - offset] |
PieceBitBoards[(int)Piece.q - offset] |
PieceBitBoards[(int)Piece.r - offset];

var enemyPiecesAttackedCount = (attacks & majorPieces).CountBits();

if (enemyPiecesAttackedCount > 1)
{
packedBonus += KnightForkBounus * enemyPiecesAttackedCount;
}

return packedBonus;
}

Expand Down
Loading

0 comments on commit 735f4ba

Please sign in to comment.