Skip to content

Commit

Permalink
Count all moves
Browse files Browse the repository at this point in the history
  • Loading branch information
eduherminio committed Nov 22, 2023
1 parent 4022a6e commit d40486a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/Lynx.Cli/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@

"IIR_MinDepth": 4,

"LMP_MaxDepth": 3,
"LMP_BaseMovesToTry": 3,
"LMP_MaxDepth": 2,
"LMP_BaseMovesToTry": 0,
"LMP_MovesDepthMultiplier": 10,

"History_MaxMoveValue": 8192,

Expand Down
6 changes: 4 additions & 2 deletions src/Lynx/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,11 @@ public sealed class EngineSettings

public int IIR_MinDepth { get; set; } = 4;

public int LMP_MaxDepth { get; set; } = 3;
public int LMP_MaxDepth { get; set; } = 2;

public int LMP_BaseMovesToTry { get; set; } = 3;
public int LMP_BaseMovesToTry { get; set; } = 0;

public int LMP_MovesDepthMultiplier { get; set; } = 10;

public int History_MaxMoveValue { get; set; } = 8_192;

Expand Down
14 changes: 7 additions & 7 deletions src/Lynx/Search/NegaMax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,20 +182,20 @@ private int NegaMax(int depth, int ply, int alpha, int beta, bool parentWasNullM
}
}

for (int i = 0; i < pseudoLegalMoves.Length; ++i)
for (int moveIndex = 0; moveIndex < pseudoLegalMoves.Length; ++moveIndex)
{
// Incremental move sorting, inspired by https://github.com/jw1912/Chess-Challenge and suggested by toanth
// There's no need to sort all the moves since most of them don't get checked anyway
// So just find the first unsearched one with the best score and try it
for (int j = i + 1; j < pseudoLegalMoves.Length; j++)
for (int j = moveIndex + 1; j < pseudoLegalMoves.Length; j++)
{
if (scores[j] > scores[i])
if (scores[j] > scores[moveIndex])
{
(scores[i], scores[j], pseudoLegalMoves[i], pseudoLegalMoves[j]) = (scores[j], scores[i], pseudoLegalMoves[j], pseudoLegalMoves[i]);
(scores[moveIndex], scores[j], pseudoLegalMoves[moveIndex], pseudoLegalMoves[j]) = (scores[j], scores[moveIndex], pseudoLegalMoves[j], pseudoLegalMoves[moveIndex]);
}
}

var move = pseudoLegalMoves[i];
var move = pseudoLegalMoves[moveIndex];

var gameState = position.MakeMove(move);

Expand Down Expand Up @@ -236,8 +236,8 @@ private int NegaMax(int depth, int ply, int alpha, int beta, bool parentWasNullM
if (!pvNode
&& !isInCheck
&& depth <= Configuration.EngineSettings.LMP_MaxDepth
&& scores[i] < EvaluationConstants.PromotionMoveScoreValue // Quiet moves
&& i >= Configuration.EngineSettings.LMP_BaseMovesToTry + 10 * depth) // Based on SP and Altair
&& scores[moveIndex] < EvaluationConstants.PromotionMoveScoreValue // Quiet moves
&& moveIndex >= Configuration.EngineSettings.LMP_BaseMovesToTry + (Configuration.EngineSettings.LMP_MovesDepthMultiplier * depth)) // Based on SP and Altair
{
// After making a move
Game.HalfMovesWithoutCaptureOrPawnMove = oldValue;
Expand Down

0 comments on commit d40486a

Please sign in to comment.