Skip to content

Commit

Permalink
Merge with origin/main: all histories cleared
Browse files Browse the repository at this point in the history
  • Loading branch information
eduherminio committed Feb 9, 2024
2 parents 896b7b1 + a0d8634 commit 0b582ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 9 additions & 1 deletion src/Lynx/Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Lynx.UCI.Commands.Engine;
using Lynx.UCI.Commands.GUI;
using NLog;
using System;
using System.Threading.Channels;

namespace Lynx;
Expand Down Expand Up @@ -83,12 +84,17 @@ public void NewGame()
Game = new Game();
_isNewGameComing = true;
_isNewGameCommandSupported = true;
InitializeTT();

InitializeTT(); // TODO SPRT clearing instead

// Clear histories
for (int i = 0; i < 12; ++i)
{
Array.Clear(_quietHistory[i]);
for (var j = 0; j < 64; ++j)
{
Array.Clear(_captureHistory[i][j]);

//for (int contPly = 0; contPly < 2; ++contPly)
//{

Expand All @@ -99,6 +105,8 @@ public void NewGame()
//}
}
}

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

public void AdjustPosition(ReadOnlySpan<char> rawPositionCommand)
Expand Down
8 changes: 0 additions & 8 deletions src/Lynx/Search/IDDFS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ public sealed partial class Engine
private bool _isScoringPV;

private SearchResult? _previousSearchResult;
private readonly int[][] _previousKillerMoves =
[
new int[Configuration.EngineSettings.MaxDepth],
new int[Configuration.EngineSettings.MaxDepth],
new int[Configuration.EngineSettings.MaxDepth]
];

private readonly Move _defaultMove = default;

Expand Down Expand Up @@ -168,8 +162,6 @@ public sealed partial class Engine
lastSearchResult = UpdateLastSearchResult(lastSearchResult, bestEvaluation, alpha, beta, depth, isMateDetected, bestEvaluationAbs);

await _engineWriter.WriteAsync(InfoCommand.SearchResultInfo(lastSearchResult));

Array.Copy(_killerMoves, _previousKillerMoves, _killerMoves.Length);
} while (StopSearchCondition(++depth, maxDepth, isMateDetected, decisionTime));
}
catch (OperationCanceledException)
Expand Down

0 comments on commit 0b582ed

Please sign in to comment.