From a0d8634ea6560e47d91271de4c7116e921f70425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20C=C3=A1ceres?= Date: Fri, 9 Feb 2024 12:17:05 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Clear=20history=20on=20`newgame`?= =?UTF-8?q?=20(#649)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Clear history on `newgame` * Cleanup after fake ponder hit removal --- src/Lynx/Engine.cs | 15 ++++++++++++++- src/Lynx/Search/IDDFS.cs | 8 -------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Lynx/Engine.cs b/src/Lynx/Engine.cs index b57e5c538..4f074cd55 100644 --- a/src/Lynx/Engine.cs +++ b/src/Lynx/Engine.cs @@ -72,7 +72,20 @@ 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]); + } + } + + // No need to clear killer move or pv table because they're cleared on every search (IDDFS) } public void AdjustPosition(ReadOnlySpan rawPositionCommand) diff --git a/src/Lynx/Search/IDDFS.cs b/src/Lynx/Search/IDDFS.cs index 473c624a8..30f091702 100644 --- a/src/Lynx/Search/IDDFS.cs +++ b/src/Lynx/Search/IDDFS.cs @@ -40,12 +40,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; @@ -151,8 +145,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)