]> git.sesse.net Git - stockfish/commitdiff
Scale contempt factor to zero at endgame
authorMarco Costalba <mcostalba@gmail.com>
Sat, 13 Oct 2012 08:40:38 +0000 (10:40 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 13 Oct 2012 08:40:38 +0000 (10:40 +0200)
Contempt Factor is more effective at opening/middle game
and seems harmful at endgame phase. See:

http://chessprogramming.wikispaces.com/Contempt+Factor

http://web.archive.org/web/20070707023203/www.brucemo.com/compchess/programming/contempt.htm

Therefore we scale down the contempt factor while going
on with the game so to reach zero at endgame phase.

No functional change.

src/search.cpp

index cf98ca35af3878dbfd5043da2446970236c1157f..ca23aa373cb342f60ab2f3e4a7f885a8d3d2537d 100644 (file)
@@ -175,8 +175,9 @@ void Search::think() {
   Position& pos = RootPosition;
   Chess960 = pos.is_chess960();
   Eval::RootColor = pos.side_to_move();
   Position& pos = RootPosition;
   Chess960 = pos.is_chess960();
   Eval::RootColor = pos.side_to_move();
-  Eval::ValueDraw[ Eval::RootColor] = VALUE_DRAW - Eval::ContemptFactor;
-  Eval::ValueDraw[~Eval::RootColor] = VALUE_DRAW + Eval::ContemptFactor;
+  int scaledCF = Eval::ContemptFactor * MaterialTable::game_phase(pos) / PHASE_MIDGAME;
+  Eval::ValueDraw[ Eval::RootColor] = VALUE_DRAW - Value(scaledCF);
+  Eval::ValueDraw[~Eval::RootColor] = VALUE_DRAW + Value(scaledCF);
   TimeMgr.init(Limits, pos.startpos_ply_counter(), pos.side_to_move());
   TT.new_search();
   H.clear();
   TimeMgr.init(Limits, pos.startpos_ply_counter(), pos.side_to_move());
   TT.new_search();
   H.clear();