]> git.sesse.net Git - stockfish/commitdiff
Add experimental contempt factor
authorMarco Costalba <mcostalba@gmail.com>
Fri, 5 Oct 2012 06:23:56 +0000 (08:23 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Fri, 5 Oct 2012 06:28:23 +0000 (08:28 +0200)
This is very crude and very basic: simply in case
of a draw for repetition or 50 moves rule return
a negative score instead of zero according to the
contempt factor (in centipawns). If contempt is
positive engine will try to avoid draws (to use
with weaker opponents), if negative engine will
try to draw. If zero (default) there are no changes.

No functional change.

src/evaluate.cpp
src/evaluate.h
src/search.cpp
src/ucioption.cpp

index b5b51d2cdc6ddecd295b0d1474b683436bbe1a82..fdfacc10b910f71d0a7a802afd8f0d8d33efda46 100644 (file)
@@ -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;
   }
 
 
index a0418b79d4760c84e07edd897b1ca183ea3ea1ff..9c2b2a61b0439abea503bbf8fd4ec6e794f57b6d 100644 (file)
@@ -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);
index 31edcc2f8845e37774cfb915163bccdcd2cc3577..77300708f1331104a07f744c9a703cc0aa1770f6 100644 (file)
@@ -546,7 +546,7 @@ namespace {
     {
         // Step 2. Check for aborted search and immediate draw
         if (Signals.stop || pos.is_draw<false>() || 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<true>() || 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
index bbbbbbf9c8475a32d728cfb485f89d8b9c521eae..1cdd4f2bb63dde0ab9f74af9e0666a0f5079dabf 100644 (file)
@@ -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);