diff --git a/src/evaluate.cpp b/src/evaluate.cpp index b5b51d2c..fdfacc10 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -268,6 +268,7 @@ namespace { namespace Eval { Color RootColor; + Value ValueDrawContempt; /// evaluate() is the main evaluation function. It always computes two /// values, an endgame score and a middle game score, and interpolates @@ -307,6 +308,8 @@ namespace Eval { KingDangerTable[1][i] = apply_weight(make_score(t, 0), Weights[KingDangerUs]); KingDangerTable[0][i] = apply_weight(make_score(t, 0), Weights[KingDangerThem]); } + + ValueDrawContempt = VALUE_DRAW - Options["Contempt Factor"] * PawnValueMg / 100; } diff --git a/src/evaluate.h b/src/evaluate.h index a0418b79..9c2b2a61 100644 --- a/src/evaluate.h +++ b/src/evaluate.h @@ -27,6 +27,7 @@ class Position; namespace Eval { extern Color RootColor; +extern Value ValueDrawContempt; extern void init(); extern Value evaluate(const Position& pos, Value& margin); diff --git a/src/search.cpp b/src/search.cpp index 31edcc2f..77300708 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -546,7 +546,7 @@ namespace { { // Step 2. Check for aborted search and immediate draw if (Signals.stop || pos.is_draw() || ss->ply > MAX_PLY) - return VALUE_DRAW; + return Eval::ValueDrawContempt; // Step 3. Mate distance pruning. Even if we mate at the next move our score // would be at best mate_in(ss->ply+1), but if alpha is already bigger because @@ -1101,7 +1101,7 @@ split_point_start: // At split points actual search starts from here // Check for an instant draw or maximum ply reached if (pos.is_draw() || ss->ply > MAX_PLY) - return VALUE_DRAW; + return Eval::ValueDrawContempt; // Decide whether or not to include checks, this fixes also the type of // TT entry depth that we are going to use. Note that in qsearch we use diff --git a/src/ucioption.cpp b/src/ucioption.cpp index bbbbbbf9..1cdd4f2b 100644 --- a/src/ucioption.cpp +++ b/src/ucioption.cpp @@ -64,6 +64,7 @@ void init(OptionsMap& o) { o["Search Log Filename"] = Option("SearchLog.txt"); o["Book File"] = Option("book.bin"); o["Best Book Move"] = Option(false); + o["Contempt Factor"] = Option(0, -50, 50, on_eval); o["Mobility (Middle Game)"] = Option(100, 0, 200, on_eval); o["Mobility (Endgame)"] = Option(100, 0, 200, on_eval); o["Passed Pawns (Middle Game)"] = Option(100, 0, 200, on_eval);