Skip to content

Commit

Permalink
Pass TT from outside
Browse files Browse the repository at this point in the history
  • Loading branch information
eduherminio committed Nov 11, 2024
1 parent 3d01404 commit 5fb483d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/Lynx.Cli/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Lynx;
using Lynx.Cli;
using Lynx.Model;
using Lynx.UCI.Commands.Engine;
using Microsoft.Extensions.Configuration;
using NLog;
Expand Down Expand Up @@ -32,7 +33,10 @@
using CancellationTokenSource source = new();
CancellationToken cancellationToken = source.Token;

var engine = new Engine(engineChannel);
var ttLength = TranspositionTableExtensions.CalculateLength(Configuration.EngineSettings.TranspositionTableSize);
var tt = GC.AllocateArray<TranspositionTableElement>(ttLength, pinned: true);

var engine = new Engine(engineChannel, tt);
var uciHandler = new UCIHandler(uciChannel, engineChannel, engine);

var tasks = new List<Task>
Expand Down
4 changes: 2 additions & 2 deletions src/Lynx/Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public sealed partial class Engine
private CancellationTokenSource _searchCancellationTokenSource;
private CancellationTokenSource _absoluteSearchCancellationTokenSource;

public Engine(ChannelWriter<object> engineWriter)
public Engine(ChannelWriter<object> engineWriter, TranspositionTable tt)
{
AverageDepth = 0;
Game = new Game(Constants.InitialPositionFEN);
Expand All @@ -73,7 +73,7 @@ public Engine(ChannelWriter<object> engineWriter)
_killerMoves[i] = new Move[3];
}

AllocateTT();
_tt = tt;

#if !DEBUG
// Temporary channel so that no output is generated
Expand Down

0 comments on commit 5fb483d

Please sign in to comment.