Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃攳 Add third killer move #517

Merged
merged 5 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Lynx/EvaluationConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,9 @@ static EvaluationConstants()

public const int SecondKillerMoveValue = 262_144;

public const int PromotionMoveScoreValue = 131_072;
public const int ThirdKillerMoveValue = 131_072;

public const int PromotionMoveScoreValue = 65_536;

//public const int MaxHistoryMoveValue => Configuration.EngineSettings.MaxHistoryMoveValue;

Expand Down
5 changes: 5 additions & 0 deletions src/Lynx/Search/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ internal int ScoreMove(Move move, int depth, bool useKillerAndPositionMoves, Mov
return EvaluationConstants.SecondKillerMoveValue;
}

if (_killerMoves[2, depth] == move)
{
return EvaluationConstants.ThirdKillerMoveValue;
}

// History move or 0 if not found
return EvaluationConstants.BaseMoveScore + _historyMoves[move.Piece(), move.TargetSquare()];
}
Expand Down
5 changes: 3 additions & 2 deletions src/Lynx/Search/IDDFS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public sealed partial class Engine
{
private readonly Stopwatch _stopWatch = new();
private readonly Move[] _pVTable = new Move[Configuration.EngineSettings.MaxDepth * (Configuration.EngineSettings.MaxDepth + 1) / 2];
private readonly int[,] _killerMoves = new int[2, Configuration.EngineSettings.MaxDepth];
private readonly int[,] _killerMoves = new int[3, Configuration.EngineSettings.MaxDepth];
private readonly int[,] _historyMoves = new int[12, 64];
private readonly int[] _maxDepthReached = new int[Constants.AbsoluteMaxDepth];
private TranspositionTable _tt = Array.Empty<TranspositionTableElement>();
Expand All @@ -21,7 +21,7 @@ public sealed partial class Engine
private bool _isScoringPV;

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

private readonly Move _defaultMove = default;

Expand Down Expand Up @@ -265,6 +265,7 @@ private int CheckPonderHit(ref SearchResult? lastSearchResult, int depth)
{
_killerMoves[0, d] = _previousKillerMoves[0, d + 2];
_killerMoves[1, d] = _previousKillerMoves[1, d + 2];
_killerMoves[2, d] = _previousKillerMoves[2, d + 2];
}

// Re-search from depth 1
Expand Down
1 change: 1 addition & 0 deletions src/Lynx/Search/NegaMax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ private int NegaMax(int depth, int ply, int alpha, int beta, bool parentWasNullM
// 馃攳 Killer moves
if (!move.IsCapture() && move.PromotedPiece() == default && move != _killerMoves[0, ply])
{
_killerMoves[2, ply] = _killerMoves[1, ply];
_killerMoves[1, ply] = _killerMoves[0, ply];
_killerMoves[0, ply] = move;
}
Expand Down