Skip to content

Commit

Permalink
Remove passed pawns
Browse files Browse the repository at this point in the history
  • Loading branch information
eduherminio committed May 16, 2024
1 parent 3f075ee commit 638e715
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 62 deletions.
42 changes: 4 additions & 38 deletions src/Lynx.Cli/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@
"FP_Margin": 250,

// Evaluation
//"DoubledPawnPenalty": {
// "MG": -6,
// "EG": -12
//},
"DoubledPawnPenalty": {
"MG": -6,
"EG": -12
},
"IsolatedPawnPenalty": {
"MG": -17,
"EG": -13
Expand Down Expand Up @@ -101,40 +101,6 @@
"BishopPairBonus": {
"MG": 31,
"EG": 80
},
"PassedPawnBonus": {
"Rank0": {
"MG": 0,
"EG": 0
},
"Rank1": {
"MG": -2,
"EG": 7
},
"Rank2": {
"MG": -15,
"EG": 13
},
"Rank3": {
"MG": -14,
"EG": 41
},
"Rank4": {
"MG": 20,
"EG": 74
},
"Rank5": {
"MG": 60,
"EG": 150
},
"Rank6": {
"MG": 98,
"EG": 217
},
"Rank7": {
"MG": 0,
"EG": 0
}
}
// End of evaluation
},
Expand Down
20 changes: 10 additions & 10 deletions src/Lynx/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public sealed class EngineSettings

#region Evaluation

//public TaperedEvaluationTerm DoubledPawnPenalty { get; set; } = new(-6, -12);
public TaperedEvaluationTerm DoubledPawnPenalty { get; set; } = new(-6, -12);

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

Expand All @@ -225,15 +225,15 @@ public sealed class EngineSettings

public TaperedEvaluationTerm BishopPairBonus { get; set; } = new(31, 80);

public TaperedEvaluationTermByRank PassedPawnBonus { get; set; } = new(
new(0, 0),
new(-2, 7),
new(-15, 13),
new(-14, 41),
new(20, 74),
new(60, 150),
new(98, 217),
new(0, 0));
//public TaperedEvaluationTermByRank PassedPawnBonus { get; set; } = new(
// new(0, 0),
// new(-2, 7),
// new(-15, 13),
// new(-14, 41),
// new(20, 74),
// new(60, 150),
// new(98, 217),
// new(0, 0));

#endregion
}
Expand Down
28 changes: 14 additions & 14 deletions src/Lynx/Model/Position.cs
Original file line number Diff line number Diff line change
Expand Up @@ -867,26 +867,26 @@ private int PawnAdditionalEvaluation(int squareIndex, int pieceIndex)
{
int packedBonus = 0;

//var doublePawnsCount = (PieceBitBoards[pieceIndex] & Masks.FileMasks[squareIndex]).CountBits();
//if (doublePawnsCount > 1)
//{
// packedBonus += doublePawnsCount * Configuration.EngineSettings.DoubledPawnPenalty.PackedEvaluation;
//}
var doublePawnsCount = (PieceBitBoards[pieceIndex] & Masks.FileMasks[squareIndex]).CountBits();
if (doublePawnsCount > 1)
{
packedBonus += doublePawnsCount * Configuration.EngineSettings.DoubledPawnPenalty.PackedEvaluation;
}

if ((PieceBitBoards[pieceIndex] & Masks.IsolatedPawnMasks[squareIndex]) == default) // isIsolatedPawn
{
packedBonus += Configuration.EngineSettings.IsolatedPawnPenalty.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;
}
//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;
//}

return packedBonus;
}
Expand Down

0 comments on commit 638e715

Please sign in to comment.