Skip to content

Commit

Permalink
Remove king shield bonus
Browse files Browse the repository at this point in the history
  • Loading branch information
eduherminio committed May 16, 2024
1 parent df0c6b3 commit 85f4854
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 63 deletions.
4 changes: 0 additions & 4 deletions src/Lynx.Cli/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@
"MG": -105,
"EG": 8
},
"KingShieldBonus": {
"MG": 16,
"EG": -6
},
"BishopPairBonus": {
"MG": 31,
"EG": 80
Expand Down
2 changes: 0 additions & 2 deletions src/Lynx/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,6 @@ public sealed class EngineSettings

public TaperedEvaluationTerm OpenFileKingPenalty { get; set; } = new(-105, 8);

public TaperedEvaluationTerm KingShieldBonus { get; set; } = new(16, -6);

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

public TaperedEvaluationTermByRank PassedPawnBonus { get; set; } = new(
Expand Down
4 changes: 1 addition & 3 deletions src/Lynx/Model/Position.cs
Original file line number Diff line number Diff line change
Expand Up @@ -969,9 +969,7 @@ internal int KingAdditionalEvaluation(int squareIndex, Side kingSide)
}
}

var ownPiecesAroundCount = (Attacks.KingAttacks[squareIndex] & OccupancyBitBoards[(int)kingSide]).CountBits();

return packedBonus + (ownPiecesAroundCount * Configuration.EngineSettings.KingShieldBonus.PackedEvaluation);
return packedBonus;
}

#endregion
Expand Down
2 changes: 1 addition & 1 deletion tests/Lynx.Test/EvaluationConstantsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class EvaluationConstantsTest
(2 * (Math.Max(MiddleGameKnightTable.Max(), EndGameKnightTable.Max()))) +
(2 * (Math.Max(MiddleGameRookTable.Max(), EndGameRookTable.Max()) + Configuration.EngineSettings.OpenFileRookBonus.MG + Configuration.EngineSettings.SemiOpenFileRookBonus.MG)) +
(9 * (Math.Max(MiddleGameQueenTable.Max(), EndGameQueenTable.Max()) + (Configuration.EngineSettings.QueenMobilityBonus.MG * 64))) +
(1 * (Math.Max(MiddleGameKingTable.Max(), EndGameKingTable.Max()) + (Configuration.EngineSettings.KingShieldBonus.MG * 8))) +
(1 * (Math.Max(MiddleGameKingTable.Max(), EndGameKingTable.Max()))) +
MiddleGameQueenTable.Max(); // just in case

[TestCase(PositiveCheckmateDetectionLimit)]
Expand Down
106 changes: 53 additions & 53 deletions tests/Lynx.Test/Model/PositionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -688,59 +688,59 @@ public void StaticEvaluation_NoSemiOpenFileKingPenalty(string fen)
}
#pragma warning restore S4144 // Methods should not have identical implementations

/// <summary>
/// 8 . k . . . . . n
/// 7 . . . . . p p p
/// 6 . . . . . . . .
/// 5 . . . . . . . .
/// 4 . . . . . . . .
/// 3 . . . . . . . .
/// 2 P P P . . . . .
/// 1 . K . . . . . N
/// a b c d e f g h
/// </summary>
/// <param name="fen"></param>
/// <param name="surroundingPieces"></param>
[TestCase("1k5n/5ppp/8/8/8/8/PPP5/1K5N w - - 0 1", 3)]
/// <summary>
/// Previous one mirrored
/// </summary>
/// <param name="fen"></param>
/// <param name="surroundingPieces"></param>
[TestCase("n5k1/5ppp/8/8/8/8/PPP5/N5K1 b - - 0 1", 3)]
/// <summary>
/// 8 . k . . . b . b
/// 7 . . . . . n n n
/// 6 . . . . . . . .
/// 5 . . . . . . . .
/// 4 . . . . . . . .
/// 3 . . . . . . . .
/// 2 N N N . . . . .
/// 1 B K B . . . . .
/// a b c d e f g h
/// </summary>
/// <param name="fen"></param>
/// <param name="surroundingPieces"></param>
[TestCase("1k3b1b/5nnn/8/8/8/8/NNN5/BKB5 w - - 0 1", 5)]
/// <summary>
/// Previous one mirrored
/// </summary>
/// <param name="fen"></param>
/// <param name="surroundingPieces"></param>
[TestCase("5bkb/5nnn/8/8/8/8/NNN5/B1B3K1 b - - 0 1", 5)]
public void StaticEvaluation_KingShieldBonus(string fen, int surroundingPieces)
{
Position position = new Position(fen);
int evaluation = AdditionalKingEvaluation(position, Piece.K)
- AdditionalKingEvaluation(position, Piece.k);

if (position.Side == Side.Black)
{
evaluation = -evaluation;
}

Assert.AreEqual(surroundingPieces * Configuration.EngineSettings.KingShieldBonus.EG, evaluation);
}
///// <summary>
///// 8 . k . . . . . n
///// 7 . . . . . p p p
///// 6 . . . . . . . .
///// 5 . . . . . . . .
///// 4 . . . . . . . .
///// 3 . . . . . . . .
///// 2 P P P . . . . .
///// 1 . K . . . . . N
///// a b c d e f g h
///// </summary>
///// <param name="fen"></param>
///// <param name="surroundingPieces"></param>
//[TestCase("1k5n/5ppp/8/8/8/8/PPP5/1K5N w - - 0 1", 3)]
///// <summary>
///// Previous one mirrored
///// </summary>
///// <param name="fen"></param>
///// <param name="surroundingPieces"></param>
//[TestCase("n5k1/5ppp/8/8/8/8/PPP5/N5K1 b - - 0 1", 3)]
///// <summary>
///// 8 . k . . . b . b
///// 7 . . . . . n n n
///// 6 . . . . . . . .
///// 5 . . . . . . . .
///// 4 . . . . . . . .
///// 3 . . . . . . . .
///// 2 N N N . . . . .
///// 1 B K B . . . . .
///// a b c d e f g h
///// </summary>
///// <param name="fen"></param>
///// <param name="surroundingPieces"></param>
//[TestCase("1k3b1b/5nnn/8/8/8/8/NNN5/BKB5 w - - 0 1", 5)]
///// <summary>
///// Previous one mirrored
///// </summary>
///// <param name="fen"></param>
///// <param name="surroundingPieces"></param>
//[TestCase("5bkb/5nnn/8/8/8/8/NNN5/B1B3K1 b - - 0 1", 5)]
//public void StaticEvaluation_KingShieldBonus(string fen, int surroundingPieces)
//{
// Position position = new Position(fen);
// int evaluation = AdditionalKingEvaluation(position, Piece.K)
// - AdditionalKingEvaluation(position, Piece.k);

// if (position.Side == Side.Black)
// {
// evaluation = -evaluation;
// }

// Assert.AreEqual(surroundingPieces * Configuration.EngineSettings.KingShieldBonus.EG, evaluation);
//}

/// <summary>
/// 8 n . . . k . . .
Expand Down

0 comments on commit 85f4854

Please sign in to comment.