Skip to content

Commit

Permalink
Add knight forks impl and tuned values, when attacks >=1
Browse files Browse the repository at this point in the history
  • Loading branch information
eduherminio committed Nov 22, 2024
1 parent eaec907 commit fb92d7b
Show file tree
Hide file tree
Showing 3 changed files with 3,789 additions and 3,766 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
static partial class EvaluationParams
{
/// <summary>
/// <see cref="Utils.Pack(-17, -14)"/>
/// <see cref="Utils.Pack(-16, -14)"/>
/// </summary>
public const int IsolatedPawnPenalty = -917521;
public const int IsolatedPawnPenalty = -917520;

/// <summary>
/// <see cref="Utils.Pack(40, 2)"/>
Expand Down Expand Up @@ -43,8 +43,8 @@ static partial class EvaluationParams
public const int PieceProtectedByPawnBonus = 983052;

/// <summary>
/// <see cref="Utils.Pack(-47, -33)"/>
/// <see cref="Utils.Pack(-49, -32)"/>
/// </summary>
public const int PieceAttackedByPawnPenalty = -2162735;
public const int PieceAttackedByPawnPenalty = -2097201;

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

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

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

// Forks
var enemyPiecesAttackedCount = (attacks & OccupancyBitBoards[Utils.OppositeSide(pieceSide)]).CountBits();

if (enemyPiecesAttackedCount != 0)
{
packedBonus += KnightForkBounus[enemyPiecesAttackedCount];
}

return packedBonus;
}

Expand Down
Loading

0 comments on commit fb92d7b

Please sign in to comment.