Skip to content

Commit

Permalink
Merge branch 'main' into search/qsearch-ttscore-as-eval-2
Browse files Browse the repository at this point in the history
  • Loading branch information
eduherminio authored Jan 18, 2025
2 parents f9d91ac + 059e1c4 commit 23524ca
Show file tree
Hide file tree
Showing 15 changed files with 6,190 additions and 5,440 deletions.
6 changes: 3 additions & 3 deletions src/Lynx.Cli/Lynx.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.1" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.15" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Lynx/Bench.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public partial class Engine
"3qr2k/1p3rbp/2p3p1/p7/P2pBNn1/1P3n2/6P1/B1Q1RR1K b - - 1 30",
"3qk1b1/1p4r1/1n4r1/2P1b2B/p3N2p/P2Q3P/8/1R3R1K w - - 2 39",

"6RR/4bP2/8/8/5r2/3K4/5p2/4k3 w - - 0 0", // SEE test suite - regular promotion
"6RR/4bP2/8/8/5r2/3K4/5p2/4k3 w - - 0 1", // SEE test suite - regular promotion
"1n2kb1r/p1P4p/2qb4/5pP1/4n2Q/8/PP1PPP1P/RNB1KBNR w KQk - 0 1", // SEE test suite - promotion with capture
"6Q1/8/1kp4P/2q1p3/2PpP3/2nP2P1/p7/5BK1 b - - 1 35", // Fischer vs Petrosian - double promotion
"5R2/2k3PK/8/5N2/7P/5q2/8/q7 w - - 0 69", // McShane - Aronian 2012 - knight promotion
Expand Down
7 changes: 7 additions & 0 deletions src/Lynx/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,13 @@ public static class Constants
[7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 6, 5, 4, 4, 4, 4, 4, 4, 6, 5, 4, 3, 3, 3, 3, 3, 6, 5, 4, 3, 2, 2, 2, 2, 6, 5, 4, 3, 2, 1, 1, 1, 6, 5, 4, 3, 2, 1, 0, 1],
[7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 7, 6, 5, 5, 5, 5, 5, 5, 7, 6, 5, 4, 4, 4, 4, 4, 7, 6, 5, 4, 3, 3, 3, 3, 7, 6, 5, 4, 3, 2, 2, 2, 7, 6, 5, 4, 3, 2, 1, 1, 7, 6, 5, 4, 3, 2, 1, 0]
];

/// <summary>
/// 262_144 * Marshal.SizeOf<PawnTableElement>() / 1024 = 4MB
/// </summary>
public const int KingPawnHashSize = 262_144;

public const int KingPawnHashMask = KingPawnHashSize - 1;
}

#pragma warning restore IDE0055
2 changes: 2 additions & 0 deletions src/Lynx/Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ private void ResetEngine()
Array.Clear(_continuationHistory);
Array.Clear(_counterMoves);

Array.Clear(_pawnEvalTable);

// No need to clear killer move or pv table because they're cleared on every search (IDDFS)
}

Expand Down
6 changes: 3 additions & 3 deletions src/Lynx/Lynx.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.StaticAnalysis" Version="9.0.0">
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="9.0.1" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="9.0.1" />
<PackageReference Include="Microsoft.Extensions.StaticAnalysis" Version="9.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
5 changes: 4 additions & 1 deletion src/Lynx/Model/GameState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public readonly struct GameState
{
public readonly ulong ZobristKey;

public readonly ulong KingPawnKey;

public readonly int IncremetalEvalAccumulator;

public readonly BoardSquare EnPassant;
Expand All @@ -14,9 +16,10 @@ public readonly struct GameState

public readonly bool IsIncrementalEval;

public GameState(ulong zobristKey, int incrementalEvalAccumulator, BoardSquare enpassant, byte castle, bool isIncrementalEval)
public GameState(ulong zobristKey, ulong kingPawnKey, int incrementalEvalAccumulator, BoardSquare enpassant, byte castle, bool isIncrementalEval)
{
ZobristKey = zobristKey;
KingPawnKey = kingPawnKey;
IncremetalEvalAccumulator = incrementalEvalAccumulator;
EnPassant = enpassant;
Castle = castle;
Expand Down
18 changes: 18 additions & 0 deletions src/Lynx/Model/PawnTableElement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Lynx.Model;

#pragma warning disable CA1051 // Do not declare visible instance fields

public struct PawnTableElement
{
public ulong Key;

public int PackedScore;

public void Update(ulong key, int packedScore)
{
Key = key;
PackedScore = packedScore;
}
}

#pragma warning restore CA1051 // Do not declare visible instance fields
Loading

0 comments on commit 23524ca

Please sign in to comment.