Skip to content

Commit

Permalink
πŸ” Add third killer move (#517)
Browse files Browse the repository at this point in the history
  • Loading branch information
eduherminio committed Nov 29, 2023
1 parent 7c086ba commit c857fde
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
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

1 comment on commit c857fde

@eduherminio
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Progress check

8+0.08, Hash 256, no draw agreements or resignations, 8moves_v3.epd:

Score of Lynx 2043 - main vs Lynx 1.0.1: 855 - 633 - 1512  [0.537] 3000
...      Lynx 2043 - main playing White: 476 - 284 - 740  [0.564] 1500
...      Lynx 2043 - main playing Black: 379 - 349 - 772  [0.510] 1500
...      White vs Black: 825 - 663 - 1512  [0.527] 3000
Elo difference: 25.8 +/- 8.7, LOS: 100.0 %, DrawRatio: 50.4 %
SPRT: llr 0 (0.0%), lbound -inf, ubound inf

Please sign in to comment.