Skip to content

Commit

Permalink
Remove old razoring implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
eduherminio committed May 17, 2024
1 parent 19b2ee9 commit e03e933
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 84 deletions.
4 changes: 0 additions & 4 deletions src/Lynx.Cli/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@
"RFP_MaxDepth": 6,
"RFP_DepthScalingFactor": 107,

"Razoring_MaxDepth": 2,
"Razoring_Depth1Bonus": 84,
"Razoring_NotDepth1Bonus": 135,

"IIR_MinDepth": 3,

"LMP_MaxDepth": 6,
Expand Down
9 changes: 0 additions & 9 deletions src/Lynx/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,6 @@ public sealed class EngineSettings
[SPSAAttribute<int>(1, 300, 10)]
public int RFP_DepthScalingFactor { get; set; } = 107;

[SPSAAttribute<int>(1, 10, 1)]
public int Razoring_MaxDepth { get; set; } = 2;

[SPSAAttribute<int>(1, 300, 10)]
public int Razoring_Depth1Bonus { get; set; } = 84;

[SPSAAttribute<int>(1, 300, 10)]
public int Razoring_NotDepth1Bonus { get; set; } = 135;

[SPSAAttribute<int>(1, 10, 1)]
public int IIR_MinDepth { get; set; } = 3;

Expand Down
31 changes: 0 additions & 31 deletions src/Lynx/Search/NegaMax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,37 +107,6 @@ private int NegaMax(int depth, int ply, int alpha, int beta, bool parentWasNullM
return (staticEval + beta) / 2;
#pragma warning restore S3949 // Calculations should not overflow
}

// 🔍 Razoring - Strelka impl (CPW) - https://www.chessprogramming.org/Razoring#Strelka
if (depth <= Configuration.EngineSettings.Razoring_MaxDepth)
{
var score = staticEval + Configuration.EngineSettings.Razoring_Depth1Bonus;

if (score < beta) // Static evaluation + bonus indicates fail-low node
{
if (depth == 1)
{
var qSearchScore = QuiescenceSearch(ply, alpha, beta);

return qSearchScore > score
? qSearchScore
: score;
}

score += Configuration.EngineSettings.Razoring_NotDepth1Bonus;

if (score < beta) // Static evaluation indicates fail-low node
{
var qSearchScore = QuiescenceSearch(ply, alpha, beta);
if (qSearchScore < beta) // Quiescence score also indicates fail-low node
{
return qSearchScore > score
? qSearchScore
: score;
}
}
}
}
}

// 🔍 Null Move Pruning (NMP) - our position is so good that we can potentially afford giving our opponent a double move and still remain ahead of beta
Expand Down
25 changes: 0 additions & 25 deletions src/Lynx/UCIHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -366,31 +366,6 @@ private void HandleSetOption(ReadOnlySpan<char> command)
break;
}

case "razoring_maxdepth":
{
if (length > 4 && int.TryParse(command[commandItems[4]], out var value))
{
Configuration.EngineSettings.Razoring_MaxDepth = value;
}
break;
}
case "razoring_depth1bonus":
{
if (length > 4 && int.TryParse(command[commandItems[4]], out var value))
{
Configuration.EngineSettings.Razoring_Depth1Bonus = value;
}
break;
}
case "razoring_notdepth1bonus":
{
if (length > 4 && int.TryParse(command[commandItems[4]], out var value))
{
Configuration.EngineSettings.Razoring_NotDepth1Bonus = value;
}
break;
}

case "iir_mindepth":
{
if (length > 4 && int.TryParse(command[commandItems[4]], out var value))
Expand Down
15 changes: 0 additions & 15 deletions tests/Lynx.Test/ConfigurationValuesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,4 @@ namespace Lynx.Test;
[NonParallelizable]
public class ConfigurationValuesTest
{
[Test]
public void RazoringValues()
{
Assert.Greater(Configuration.EngineSettings.RFP_MaxDepth, Configuration.EngineSettings.Razoring_MaxDepth);

var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false)
.Build();

var engineSettingsSection = config.GetRequiredSection(nameof(EngineSettings));
Assert.IsNotNull(engineSettingsSection);
engineSettingsSection.Bind(Configuration.EngineSettings);

Assert.Greater(Configuration.EngineSettings.RFP_MaxDepth, Configuration.EngineSettings.Razoring_MaxDepth);
}
}

0 comments on commit e03e933

Please sign in to comment.