Merge pull request #126 from nodchip/prune_at_shallow_depth_on_pv_node-2020-09-09

Set the value of prune_at_shallow_depth_on_pv_node on a UCI option callback
This commit is contained in:
nodchip
2020-09-10 10:44:23 +09:00
committed by GitHub
3 changed files with 18 additions and 6 deletions

View File

@@ -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
&& (PvNode ? prune_at_shallow_depth_on_pv_node : true)
#endif
&& pos.non_pawn_material(us)
&& bestValue > VALUE_TB_LOSS_IN_MAX_PLY)
{

View File

@@ -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.

View File

@@ -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
}