Skip to content

Commit

Permalink
Change isolated pawn penalty to allow different values per rank
Browse files Browse the repository at this point in the history
  • Loading branch information
eduherminio committed May 17, 2024
1 parent 19b2ee9 commit c02831d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 12 deletions.
38 changes: 34 additions & 4 deletions src/Lynx.Cli/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@
"FP_Margin": 250,

// Evaluation
"IsolatedPawnPenalty": {
"MG": -21,
"EG": -17
},
"OpenFileRookBonus": {
"MG": 46,
"EG": 9
Expand Down Expand Up @@ -131,6 +127,40 @@
"MG": 0,
"EG": 0
}
},
"IsolatedPawnPenalty": {
"Rank0": {
"MG": 0,
"EG": 0
},
"Rank1": {
"MG": -5,
"EG": -5
},
"Rank2": {
"MG": -5,
"EG": -5
},
"Rank3": {
"MG": -5,
"EG": -5
},
"Rank4": {
"MG": -5,
"EG": -5
},
"Rank5": {
"MG": -5,
"EG": -5
},
"Rank6": {
"MG": -5,
"EG": -5
},
"Rank7": {
"MG": 0,
"EG": 0
}
}
// End of evaluation
},
Expand Down
12 changes: 10 additions & 2 deletions src/Lynx/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,6 @@ public sealed class EngineSettings

#region Evaluation

public TaperedEvaluationTerm IsolatedPawnPenalty { get; set; } = new(-21, -17);

public TaperedEvaluationTerm OpenFileRookBonus { get; set; } = new(46, 9);

public TaperedEvaluationTerm SemiOpenFileRookBonus { get; set; } = new(15, 15);
Expand Down Expand Up @@ -233,6 +231,16 @@ public sealed class EngineSettings
new(104, 243),
new(0, 0));

public TaperedEvaluationTermByRank IsolatedPawnPenalty { get; set; } = new(
new(0, 0),
new(-5, -5),
new(-5, -5),
new(-5, -5),
new(-5, -5),
new(-5, -5),
new(-5, -5),
new(0, 0));

#endregion
}

Expand Down
13 changes: 7 additions & 6 deletions src/Lynx/Model/Position.cs
Original file line number Diff line number Diff line change
Expand Up @@ -867,18 +867,19 @@ private int PawnAdditionalEvaluation(int squareIndex, int pieceIndex)
{
int packedBonus = 0;

var rank = Constants.Rank[squareIndex];
if (pieceIndex == (int)Piece.p)
{
rank = 7 - rank;
}

if ((PieceBitBoards[pieceIndex] & Masks.IsolatedPawnMasks[squareIndex]) == default) // isIsolatedPawn
{
packedBonus += Configuration.EngineSettings.IsolatedPawnPenalty.PackedEvaluation;
packedBonus += Configuration.EngineSettings.IsolatedPawnPenalty[rank].PackedEvaluation;
}

if ((PieceBitBoards[(int)Piece.p - pieceIndex] & Masks.PassedPawns[pieceIndex][squareIndex]) == default) // isPassedPawn
{
var rank = Constants.Rank[squareIndex];
if (pieceIndex == (int)Piece.p)
{
rank = 7 - rank;
}
packedBonus += Configuration.EngineSettings.PassedPawnBonus[rank].PackedEvaluation;
}

Expand Down

0 comments on commit c02831d

Please sign in to comment.