Skip to content

Commit

Permalink
⚖️ Add rook mobility to eval (#539)
Browse files Browse the repository at this point in the history
  • Loading branch information
eduherminio committed Dec 20, 2023
1 parent 6d3db5f commit 15fadcc
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 143 deletions.
50 changes: 27 additions & 23 deletions src/Lynx.Cli/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,36 +51,40 @@
"EG": -14
},
"IsolatedPawnPenalty": {
"MG": -17,
"MG": -18,
"EG": -14
},
"OpenFileRookBonus": {
"MG": 60,
"EG": 28
"MG": 46,
"EG": 13
},
"SemiOpenFileRookBonus": {
"MG": 25,
"EG": 23
"MG": 17,
"EG": 19
},
"BishopMobilityBonus": {
"MG": 10,
"EG": 10
},
"RookMobilityBonus": {
"MG": 5,
"EG": 5
},
"QueenMobilityBonus": {
"MG": 3,
"EG": 9
"MG": 4,
"EG": 8
},
"SemiOpenFileKingPenalty": {
"MG": -38,
"EG": 25
},
"OpenFileKingPenalty": {
"MG": -107,
"EG": 4
"MG": -109,
"EG": 6
},
"KingShieldBonus": {
"MG": 19,
"EG": -6
"MG": 17,
"EG": -5
},
"BishopPairBonus": {
"MG": 30,
Expand All @@ -92,28 +96,28 @@
"EG": 0
},
"Rank1": {
"MG": -2,
"EG": 7
"MG": -1,
"EG": 5
},
"Rank2": {
"MG": -16,
"EG": 13
"MG": -15,
"EG": 12
},
"Rank3": {
"MG": -16,
"EG": 44
"MG": -15,
"EG": 43
},
"Rank4": {
"MG": 20,
"EG": 83
"MG": 19,
"EG": 84
},
"Rank5": {
"MG": 61,
"EG": 175
"MG": 53,
"EG": 176
},
"Rank6": {
"MG": 92,
"EG": 257
"MG": 74,
"EG": 260
},
"Rank7": {
"MG": 0,
Expand Down
26 changes: 14 additions & 12 deletions src/Lynx/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,32 +166,34 @@ public sealed class EngineSettings

public TaperedEvaluationTerm DoubledPawnPenalty { get; set; } = new(-5, -14);

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

public TaperedEvaluationTerm OpenFileRookBonus { get; set; } = new(60, 28);
public TaperedEvaluationTerm OpenFileRookBonus { get; set; } = new(46, 13);

public TaperedEvaluationTerm SemiOpenFileRookBonus { get; set; } = new(25, 23);
public TaperedEvaluationTerm SemiOpenFileRookBonus { get; set; } = new(17, 19);

public TaperedEvaluationTerm BishopMobilityBonus { get; set; } = new(10, 10);

public TaperedEvaluationTerm QueenMobilityBonus { get; set; } = new(3, 9);
public TaperedEvaluationTerm RookMobilityBonus { get; set; } = new(5, 5);

public TaperedEvaluationTerm QueenMobilityBonus { get; set; } = new(4, 8);

public TaperedEvaluationTerm SemiOpenFileKingPenalty { get; set; } = new(-38, 25);

public TaperedEvaluationTerm OpenFileKingPenalty { get; set; } = new(-107, 4);
public TaperedEvaluationTerm OpenFileKingPenalty { get; set; } = new(-109, 6);

public TaperedEvaluationTerm KingShieldBonus { get; set; } = new(19, -6);
public TaperedEvaluationTerm KingShieldBonus { get; set; } = new(17, -5);

public TaperedEvaluationTerm BishopPairBonus { get; set; } = new(30, 88);

public TaperedEvaluationTermByRank PassedPawnBonus { get; set; } = new(
new(0),
new(-2, 7),
new(-16, 13),
new(-16, 44),
new(20, 83),
new(61, 175),
new(92, 257),
new(-1, 5),
new(-15, 12),
new(-15, 43),
new(19, 84),
new(53, 176),
new(74, 260),
new(0));

#endregion
Expand Down
192 changes: 96 additions & 96 deletions src/Lynx/EvaluationConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,158 +26,158 @@ public static class EvaluationConstants

public static readonly int[] MiddleGamePieceValues =
[
+102, +382, +352, +500, +1102, 0,
-102, -382, -352, -500, -1102, 0
+103, +386, +357, +475, +1084, 0,
-103, -386, -357, -475, -1084, 0
];

public static readonly int[] EndGamePieceValues =
[
+149, +484, +435, +892, +1531, 0,
-149, -484, -435, -892, -1531, 0
+149, +485, +434, +843, +1560, 0,
-149, -485, -434, -843, -1560, 0
];

public static readonly int[] MiddleGamePawnTable =
[
0, 0, 0, 0, 0, 0, 0, 0,
-31, -22, -15, -11, -4, 25, 31, -18,
-29, -24, -5, 11, 19, 27, 26, 7,
-23, -14, 5, 20, 29, 34, 5, -3,
-23, -10, 3, 21, 30, 30, 4, -4,
-26, -18, -3, 4, 15, 22, 18, 1,
-31, -20, -20, -15, -7, 19, 20, -25,
-26, -23, -15, -9, -3, 29, 31, -15,
-27, -25, -5, 11, 18, 27, 24, 7,
-27, -15, 3, 18, 27, 30, 3, -6,
-26, -11, 1, 19, 27, 27, 2, -7,
-24, -19, -3, 4, 14, 23, 17, 1,
-27, -21, -20, -14, -5, 22, 20, -22,
0, 0, 0, 0, 0, 0, 0, 0,
];

public static readonly int[] EndGamePawnTable =
[
0, 0, 0, 0, 0, 0, 0, 0,
15, 12, 7, -15, 6, 3, -4, -11,
12, 12, 0, -14, -7, -6, -3, -11,
28, 20, 0, -22, -18, -13, 8, -1,
24, 19, -2, -17, -16, -10, 5, -4,
13, 10, -4, -13, -3, -3, -2, -11,
17, 12, 9, -15, 17, 7, -1, -7,
12, 12, 6, -15, 6, 2, -4, -12,
11, 13, 0, -14, -7, -5, -2, -11,
28, 20, 0, -22, -18, -12, 8, -1,
25, 19, -2, -17, -16, -9, 6, -3,
12, 10, -4, -13, -2, -3, -1, -11,
15, 12, 9, -14, 16, 6, -1, -9,
0, 0, 0, 0, 0, 0, 0, 0,
];

public static readonly int[] MiddleGameKnightTable =
[
-155, -30, -62, -43, -21, -26, -16, -97,
-46, -25, -2, 16, 18, 23, -13, -17,
-27, 4, 22, 60, 62, 43, 38, -1,
-8, 28, 45, 62, 63, 63, 50, 22,
-4, 27, 48, 50, 60, 61, 51, 21,
-25, 6, 21, 51, 61, 36, 31, -2,
-48, -16, 1, 15, 17, 17, -10, -18,
-170, -33, -59, -33, -19, -17, -24, -91,
-153, -23, -52, -32, -12, -21, -9, -98,
-46, -27, -3, 15, 18, 25, -14, -17,
-28, 1, 20, 57, 61, 42, 35, -3,
-11, 25, 43, 60, 60, 61, 46, 18,
-8, 24, 45, 48, 57, 59, 47, 17,
-26, 3, 20, 49, 60, 35, 28, -4,
-48, -19, 0, 15, 17, 19, -11, -18,
-168, -24, -49, -21, -9, -12, -17, -91,
];

public static readonly int[] EndGameKnightTable =
[
-73, -70, -11, -12, -9, -27, -63, -93,
-21, -1, 15, 9, 12, 10, -12, -20,
-13, 17, 40, 39, 38, 20, 11, -14,
8, 21, 52, 53, 57, 51, 26, -5,
5, 28, 51, 55, 59, 47, 32, 0,
-17, 20, 29, 46, 36, 22, 7, -10,
-27, 2, 5, 13, 6, 2, -14, -24,
-79, -70, -7, -14, -10, -25, -60, -93,
-72, -61, -13, -13, -10, -28, -55, -93,
-22, -2, 15, 9, 10, 7, -13, -21,
-14, 16, 38, 38, 37, 18, 10, -15,
7, 20, 52, 53, 56, 50, 25, -6,
4, 27, 51, 55, 58, 47, 31, 0,
-18, 19, 27, 45, 35, 20, 7, -11,
-28, 2, 5, 13, 5, 0, -15, -25,
-78, -60, -9, -17, -11, -26, -53, -93,
];

public static readonly int[] MiddleGameBishopTable =
[
-13, 12, -10, -26, -20, -21, -27, 3,
8, 5, 8, -18, 1, -2, 30, -11,
-5, 8, -3, 4, -6, 14, 8, 32,
-4, -4, -4, 25, 21, -16, 5, 2,
-13, 1, -12, 19, 7, -10, -3, 8,
6, 8, 8, -5, 6, 7, 10, 27,
9, 16, 13, -7, -4, 1, 22, -2,
12, 15, 3, -42, -23, -27, -5, -12,
-15, 16, -2, -15, -10, -16, -23, 2,
8, 3, 7, -18, 1, -1, 29, -12,
-6, 5, -4, 3, -8, 14, 5, 28,
-7, -7, -6, 23, 19, -18, 2, -2,
-16, -2, -15, 17, 6, -13, -6, 5,
5, 5, 7, -5, 6, 7, 8, 24,
10, 15, 12, -6, -3, 4, 21, -2,
10, 20, 12, -29, -13, -21, 1, -12,
];

public static readonly int[] EndGameBishopTable =
[
-14, 19, -24, 5, -2, 2, 2, -31,
-4, -7, -3, 6, 5, -9, -1, -15,
15, 16, 9, 4, 14, 5, 8, 10,
13, 9, 8, -1, -5, 8, 5, 5,
8, 10, 8, 5, -9, 6, 4, 5,
13, 4, 1, 2, 7, 1, 4, 7,
-14, -10, -16, 3, 2, -1, 0, -10,
-8, -11, -17, 8, 9, 6, 0, -21,
-14, 18, -13, 3, -3, 6, 1, -31,
-5, -8, -4, 5, 4, -10, -2, -16,
14, 16, 8, 3, 12, 4, 7, 10,
13, 8, 7, -2, -6, 6, 4, 5,
9, 10, 6, 4, -10, 5, 4, 5,
12, 4, 0, 1, 5, -1, 4, 7,
-15, -11, -17, 3, 1, -3, -2, -11,
-7, -12, -7, 7, 8, 9, -2, -22,
];

public static readonly int[] MiddleGameRookTable =
[
-8, -16, -13, -9, 6, -6, 2, -6,
-30, -13, -14, -15, -3, 0, 19, -6,
-31, -15, -18, -7, 8, 11, 60, 31,
-24, -18, -12, -3, 3, 13, 50, 26,
-18, -12, -5, 4, -1, 14, 40, 23,
-24, -11, -12, 1, 6, 23, 56, 33,
-28, -24, -8, -8, -2, -2, 25, 0,
-5, -8, -8, 2, 15, -1, 11, 7,
-4, -10, -5, 2, 14, 3, 10, 0,
-27, -17, -14, -14, -2, 3, 21, 0,
-29, -19, -23, -13, 4, 9, 55, 31,
-26, -21, -18, -12, -7, 8, 44, 21,
-20, -17, -12, -5, -10, 7, 33, 16,
-24, -16, -19, -5, 1, 19, 50, 30,
-25, -28, -9, -7, -1, 1, 27, 4,
-2, -3, 1, 12, 23, 8, 17, 12,
];

public static readonly int[] EndGameRookTable =
[
6, 8, 13, 4, -6, 6, 6, -4,
16, 20, 20, 9, -1, 2, -4, 4,
9, 7, 10, 3, -9, -9, -23, -21,
12, 10, 11, 5, -4, -1, -17, -20,
12, 8, 12, 2, -1, -7, -14, -15,
12, 13, 2, -6, -11, -13, -21, -15,
21, 23, 16, 5, -3, 1, -5, 5,
0, 1, 8, -1, -13, -1, -4, -14,
6, 3, 7, -2, -11, 4, 0, -5,
15, 20, 21, 11, 0, -2, -6, 2,
11, 8, 12, 5, -9, -11, -23, -20,
15, 10, 12, 6, -2, -2, -16, -15,
14, 9, 12, 2, -1, -9, -13, -11,
12, 13, 3, -4, -11, -16, -22, -14,
20, 23, 16, 5, -3, -2, -8, 2,
1, -3, 2, -8, -18, -4, -9, -15,
];

public static readonly int[] MiddleGameQueenTable =
[
-16, -20, -20, -2, -11, -41, 5, 0,
0, -8, 9, -1, 3, 3, 23, 49,
-5, -1, -5, -5, -8, 10, 39, 62,
-9, -14, -13, -3, -4, 2, 17, 29,
-9, -9, -13, -14, -4, 1, 15, 26,
-2, 0, -12, -9, -3, 7, 24, 42,
-15, -18, 5, 9, 7, 0, 7, 36,
-12, -22, -10, 0, -9, -49, -20, 27,
-15, -10, -5, 9, 3, -32, 14, 1,
0, -10, 7, -2, 2, 6, 22, 51,
-8, -5, -10, -9, -14, 6, 35, 59,
-12, -20, -19, -9, -11, -5, 11, 25,
-12, -15, -20, -20, -10, -6, 9, 22,
-5, -3, -16, -13, -8, 4, 20, 39,
-15, -21, 3, 9, 7, 3, 6, 37,
-11, -11, 5, 11, 6, -39, -12, 28,
];

public static readonly int[] EndGameQueenTable =
[
-24, -15, -1, -13, -8, -3, -36, 12,
-19, -14, -28, -1, -1, -14, -47, 0,
-17, -7, 0, -5, 18, 21, -10, 4,
-11, 4, 0, 5, 22, 35, 45, 35,
-1, -1, 9, 21, 19, 28, 23, 48,
-19, -15, 11, 9, 14, 21, 21, 19,
-12, -8, -25, -17, -11, -7, -32, 10,
-11, -8, -8, -6, 2, 29, 21, -6,
-27, -24, -10, -9, -19, -11, -46, 6,
-22, -13, -28, 0, -2, -17, -48, -5,
-17, -7, 4, -1, 23, 23, -8, 3,
-11, 8, 5, 12, 28, 40, 49, 35,
-2, 2, 14, 26, 26, 34, 27, 48,
-20, -14, 15, 13, 19, 22, 23, 18,
-15, -6, -23, -18, -12, -10, -32, 6,
-15, -18, -17, -2, -9, 21, 13, -9,
];

public static readonly int[] MiddleGameKingTable =
[
44, 57, 27, -83, 6, -66, 45, 65,
1, -8, -29, -70, -83, -58, -3, 28,
-81, -68, -113, -117, -129, -135, -86, -99,
-119, -121, -139, -181, -171, -160, -159, -190,
-82, -86, -129, -160, -174, -144, -162, -181,
-76, -40, -106, -116, -100, -114, -77, -90,
89, 2, -30, -60, -64, -45, 12, 37,
59, 85, 40, -67, 17, -55, 60, 79,
34, 55, 30, -72, 12, -58, 44, 57,
-3, -12, -33, -74, -88, -58, -7, 23,
-83, -71, -116, -119, -133, -137, -88, -100,
-120, -119, -138, -181, -172, -160, -157, -190,
-85, -87, -128, -159, -174, -144, -161, -182,
-77, -42, -108, -119, -103, -116, -78, -92,
83, -2, -34, -64, -69, -46, 9, 32,
49, 82, 43, -55, 25, -47, 58, 70,
];

public static readonly int[] EndGameKingTable =
[
-87, -50, -24, 4, -43, -2, -40, -96,
-22, 16, 29, 43, 51, 36, 14, -24,
6, 43, 64, 76, 80, 71, 47, 25,
16, 60, 84, 102, 98, 89, 75, 47,
3, 49, 82, 98, 103, 88, 78, 45,
5, 39, 63, 77, 73, 66, 47, 20,
-47, 9, 30, 40, 43, 32, 9, -28,
-100, -62, -30, -3, -35, -6, -44, -101,
-85, -49, -22, 4, -36, -3, -41, -96,
-21, 16, 30, 43, 51, 36, 14, -24,
7, 44, 65, 77, 81, 71, 47, 25,
17, 60, 85, 102, 98, 90, 75, 47,
5, 50, 82, 98, 103, 88, 78, 46,
6, 40, 64, 77, 74, 66, 47, 20,
-45, 11, 31, 41, 44, 33, 9, -27,
-97, -61, -29, -3, -31, -7, -45, -101,
];

public static readonly int[] MiddleGamePawnTableBlack = MiddleGamePawnTable.Select((_, index) => -MiddleGamePawnTable[index ^ 56]).ToArray();
Expand Down

0 comments on commit 15fadcc

Please sign in to comment.