]> git.sesse.net Git - stockfish/commitdiff
Better document how mate scores are stored in TT
authorMarco Costalba <mcostalba@gmail.com>
Wed, 28 Dec 2011 12:22:09 +0000 (13:22 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 28 Dec 2011 12:33:31 +0000 (13:33 +0100)
During the search we score a mate as "plies to mate
from the root" to compare in an homogeneous way the
values returned by different sub-trees. However we
store in TT a mate score as "plies to mate from the
current position" the let the TT value remain valid
across the game.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/search.cpp

index c09de0ba6b061cb60e677008d9deadcca56edd15..f976908ec31b0e5b2a9f9d36235b365461a3d9e7 100644 (file)
@@ -1370,7 +1370,7 @@ split_point_start: // At split points actual search starts from here
     // All legal moves have been searched. A special case: If we're in check
     // and no legal moves were found, it is checkmate.
     if (inCheck && bestValue == -VALUE_INFINITE)
-        return mated_in(ss->ply);
+        return mated_in(ss->ply); // Plies to mate from the root
 
     // Update transposition table
     move = bestValue <= oldAlpha ? MOVE_NONE : ss->bestMove;
@@ -1495,8 +1495,8 @@ split_point_start: // At split points actual search starts from here
 
 
   // value_to_tt() adjusts a mate score from "plies to mate from the root" to
-  // "plies to mate from the current ply". Non-mate scores are unchanged. The
-  // function is called before storing a value to the transposition table.
+  // "plies to mate from the current position". Non-mate scores are unchanged.
+  // The function is called before storing a value to the transposition table.
 
   Value value_to_tt(Value v, int ply) {
 
@@ -1510,8 +1510,9 @@ split_point_start: // At split points actual search starts from here
   }
 
 
-  // value_from_tt() is the inverse of value_to_tt(): It adjusts a mate score from
-  // the transposition table to a mate score corrected for the current ply.
+  // value_from_tt() is the inverse of value_to_tt(): It adjusts a mate score
+  // from the transposition table (where refers to the plies to mate/be mated
+  // from current position) to "plies to mate/be mated from the root".
 
   Value value_from_tt(Value v, int ply) {