Skip to content

Commit

Permalink
Clear history on newgame
Browse files Browse the repository at this point in the history
  • Loading branch information
eduherminio committed Feb 8, 2024
1 parent 9d4cc9f commit 1b55587
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/Lynx/Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using Lynx.UCI.Commands.Engine;
using Lynx.UCI.Commands.GUI;
using NLog;
using System.Diagnostics;
using System.Security.Cryptography;
using System.Threading.Channels;

namespace Lynx;
Expand Down Expand Up @@ -72,7 +74,27 @@ 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]);
}
}

// Clear killer moves
Debug.Assert(_killerMoves.Length == 3);
Array.Clear(_killerMoves[0]);
Array.Clear(_killerMoves[1]);
Array.Clear(_killerMoves[2]);
// No need to clear _previousKillerMoves

// _pVTable will be cleared on IDDFS, since it needs to be cleaned for every search as well, no matter what
}

public void AdjustPosition(ReadOnlySpan<char> rawPositionCommand)
Expand Down

0 comments on commit 1b55587

Please sign in to comment.