From e63b6088ba8066844fdf47a5843355196e0e2ad1 Mon Sep 17 00:00:00 2001 From: nodchip Date: Wed, 9 Sep 2020 23:38:00 +0900 Subject: [PATCH] Changed a option name more descriptive, "Training" -> "PruneAtShallowDepthOnPvNode". The default value was changed but the default behavior is not changed. Changed to set a global option prune_at_shallow_depth_on_pv_node on a callback function. --- src/search.cpp | 12 +++++++----- src/search.h | 4 ++++ src/ucioption.cpp | 8 +++++++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index 67348a2b..6fbfdedf 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -54,6 +54,10 @@ using std::string; using Eval::evaluate; using namespace Search; +#if defined(EVAL_LEARN) +bool Search::prune_at_shallow_depth_on_pv_node = false; +#endif + namespace { // Different node types, used as a template parameter @@ -68,8 +72,6 @@ namespace { return Value(223 * (d - improving)); } - bool training; - // Reductions lookup table, initialized at startup int Reductions[MAX_MOVES]; // [depth or moveNumber] @@ -195,8 +197,6 @@ void Search::init() { for (int i = 1; i < MAX_MOVES; ++i) Reductions[i] = int((22.0 + std::log(Threads.size())) * std::log(i)); - - training = Options["Training"]; } @@ -1011,7 +1011,9 @@ moves_loop: // When in check, search starts from here // Step 12. Pruning at shallow depth (~200 Elo) if ( !rootNode - && !(training && PvNode) +#ifdef EVAL_LEARN + && !(!prune_at_shallow_depth_on_pv_node && PvNode) +#endif && pos.non_pawn_material(us) && bestValue > VALUE_TB_LOSS_IN_MAX_PLY) { diff --git a/src/search.h b/src/search.h index 01d8a4c1..9d5ce279 100644 --- a/src/search.h +++ b/src/search.h @@ -33,6 +33,10 @@ namespace Search { constexpr int CounterMovePruneThreshold = 0; +#if defined(EVAL_LEARN) +extern bool prune_at_shallow_depth_on_pv_node; +#endif + /// Stack struct keeps track of the information we need to remember from nodes /// shallower and deeper in the tree during the search. Each search thread has /// its own array of Stack objects, indexed by the current ply. diff --git a/src/ucioption.cpp b/src/ucioption.cpp index 4f9fab5e..0e561416 100644 --- a/src/ucioption.cpp +++ b/src/ucioption.cpp @@ -42,6 +42,11 @@ void on_threads(const Option& o) { Threads.set(size_t(o)); } void on_tb_path(const Option& o) { Tablebases::init(o); } void on_use_NNUE(const Option& ) { Eval::init_NNUE(); } void on_eval_file(const Option& ) { Eval::init_NNUE(); } +#ifdef EVAL_LEARN +void on_prune_at_shallow_depth_on_pv_node(const Option& o) { + Search::prune_at_shallow_depth_on_pv_node = o; +} +#endif /// Our case insensitive less() function as required by UCI protocol bool CaseInsensitiveLess::operator() (const string& s1, const string& s2) const { @@ -69,7 +74,6 @@ void init(OptionsMap& o) { o["Move Overhead"] << Option(10, 0, 5000); o["Slow Mover"] << Option(100, 10, 1000); o["nodestime"] << Option(0, 0, 10000); - o["Training"] << Option(false); o["UCI_Chess960"] << Option(false); o["UCI_AnalyseMode"] << Option(false); o["UCI_LimitStrength"] << Option(false); @@ -96,6 +100,8 @@ void init(OptionsMap& o) { // Evalsave by default. This folder shall be prepared in advance. // Automatically create a folder under this folder like "0/", "1/", ... and save the evaluation function file there. o["EvalSaveDir"] << Option("evalsave"); + // Prune at shallow depth on PV nodes. Setting this value to true gains elo in shallow search. + o["PruneAtShallowDepthOnPvNode"] << Option(false, on_prune_at_shallow_depth_on_pv_node); #endif }