Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚖ Add bonus for QRB knight forks if they include the king and the knight isn't attacked by pawns #1197

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(45, 31)"/>
/// </summary>
public const int KnightForkBounus = 2031661;

}
13 changes: 13 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,18 @@ private int KnightAdditionalEvaluation(int squareIndex, int pieceSide, int oppos

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

// Forks
if (attacks.GetBit(oppositeSideKingSquare) && !enemyPawnAttacks.GetBit(squareIndex))
{
var offset = Utils.PieceOffset(pieceSide);
var attackedOponentPieces = PieceBitBoards[(int)Piece.q - offset]
| PieceBitBoards[(int)Piece.r - offset]
| PieceBitBoards[(int)Piece.b - offset];

var enemyPiecesAttackedCount = (attacks & attackedOponentPieces).CountBits();
packedBonus += KnightForkBounus * enemyPiecesAttackedCount;
}

return packedBonus;
}

Expand Down
Loading
Loading