From d40486a6c40b8fede3754b595a6eb203ff157cf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20C=C3=A1ceres?= Date: Wed, 22 Nov 2023 04:16:39 +0100 Subject: [PATCH] Count all moves --- src/Lynx.Cli/appsettings.json | 5 +++-- src/Lynx/Configuration.cs | 6 ++++-- src/Lynx/Search/NegaMax.cs | 14 +++++++------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Lynx.Cli/appsettings.json b/src/Lynx.Cli/appsettings.json index 4220df5db..d0fa15d5f 100644 --- a/src/Lynx.Cli/appsettings.json +++ b/src/Lynx.Cli/appsettings.json @@ -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, diff --git a/src/Lynx/Configuration.cs b/src/Lynx/Configuration.cs index 972d1438a..12903dff0 100644 --- a/src/Lynx/Configuration.cs +++ b/src/Lynx/Configuration.cs @@ -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; diff --git a/src/Lynx/Search/NegaMax.cs b/src/Lynx/Search/NegaMax.cs index 573d75084..c0d281bef 100644 --- a/src/Lynx/Search/NegaMax.cs +++ b/src/Lynx/Search/NegaMax.cs @@ -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); @@ -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;