Skip to content

Commit

Permalink
Add tunable SEE piece values
Browse files Browse the repository at this point in the history
  • Loading branch information
eduherminio committed Nov 13, 2024
1 parent c590b71 commit dcb045a
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 3 deletions.
15 changes: 15 additions & 0 deletions src/Lynx/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,21 @@ public int TranspositionTableSize

[SPSA<int>(-8192, 0, 512)]
public int HistoryPrunning_Margin { get; set; } = -1940;

[SPSA<int>(0, 1500, 50)]
public int SEE_Pawn { get; set; } = 100;

[SPSA<int>(0, 1500, 50)]
public int SEE_Knight { get; set; } = 450;

[SPSA<int>(0, 1500, 50)]
public int SEE_Bishop { get; set; } = 450;

[SPSA<int>(0, 1500, 50)]
public int SEE_Rook { get; set; } = 650;

[SPSA<int>(0, 1500, 50)]
public int SEE_Queen { get; set; } = 1250;
}

[JsonSourceGenerationOptions(
Expand Down
15 changes: 12 additions & 3 deletions src/Lynx/SEE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,19 @@ public static class SEE
{
#pragma warning disable IDE0055 // Discard formatting in this region

private static ReadOnlySpan<int> _pieceValues =>
private static readonly int[] _pieceValues =
[
100, 450, 450, 650, 1250, 0,
100, 450, 450, 650, 1250, 0,
Configuration.EngineSettings.SEE_Pawn,
Configuration.EngineSettings.SEE_Knight,
Configuration.EngineSettings.SEE_Bishop,
Configuration.EngineSettings.SEE_Rook,
Configuration.EngineSettings.SEE_Queen,
0,
Configuration.EngineSettings.SEE_Pawn,
Configuration.EngineSettings.SEE_Knight,
Configuration.EngineSettings.SEE_Bishop,
Configuration.EngineSettings.SEE_Rook,
Configuration.EngineSettings.SEE_Queen,
0
];

Expand Down
40 changes: 40 additions & 0 deletions src/Lynx/UCIHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,46 @@ private void HandleSetOption(ReadOnlySpan<char> command)
}
break;
}
case "see_pawn":
{
if (length > 4 && int.TryParse(command[commandItems[4]], out var value))
{
Configuration.EngineSettings.SEE_Pawn = value;
}
break;
}
case "see_knight":
{
if (length > 4 && int.TryParse(command[commandItems[4]], out var value))
{
Configuration.EngineSettings.SEE_Knight = value;
}
break;
}
case "see_bishop":
{
if (length > 4 && int.TryParse(command[commandItems[4]], out var value))
{
Configuration.EngineSettings.SEE_Bishop = value;
}
break;
}
case "see_rook":
{
if (length > 4 && int.TryParse(command[commandItems[4]], out var value))
{
Configuration.EngineSettings.SEE_Rook = value;
}
break;
}
case "see_queen":
{
if (length > 4 && int.TryParse(command[commandItems[4]], out var value))
{
Configuration.EngineSettings.SEE_Queen = value;
}
break;
}

#endregion

Expand Down

0 comments on commit dcb045a

Please sign in to comment.