]> git.sesse.net Git - stockfish/blobdiff - src/tt.cpp
Allow SearchStack to link an EvalInfo object
[stockfish] / src / tt.cpp
index 5e1dfe1788e8432e44b511e8fce8df25d19aa8f2..1b2ae720dbe60a43826e82f457ff5254a1c0fb35 100644 (file)
@@ -55,7 +55,7 @@ TranspositionTable::~TranspositionTable() {
 
 void TranspositionTable::set_size(unsigned mbSize) {
 
-  assert(mbSize >= 4 && mbSize <= 4096);
+  assert(mbSize >= 4 && mbSize <= 2048);
 
   unsigned newSize = 1024;
 
@@ -208,7 +208,9 @@ void TranspositionTable::insert_pv(const Position& pos, Move pv[]) {
 
   for (int i = 0; pv[i] != MOVE_NONE; i++)
   {
-      store(p.get_key(), VALUE_NONE, VALUE_TYPE_NONE, Depth(-127*OnePly), pv[i]);
+      TTEntry *tte = retrieve(p.get_key());
+      if (!tte || tte->move() != pv[i])
+          store(p.get_key(), VALUE_NONE, VALUE_TYPE_NONE, Depth(-127*OnePly), pv[i]);
       p.do_move(pv[i], st);
   }
 }
@@ -220,7 +222,7 @@ void TranspositionTable::insert_pv(const Position& pos, Move pv[]) {
 /// will often get single-move PVs when the search stops while failing high,
 /// and a single-move PV means that we don't have a ponder move.
 
-void TranspositionTable::extract_pv(const Position& pos, Move pv[], int pvSize) {
+void TranspositionTable::extract_pv(const Position& pos, Move pv[], const int PLY_MAX) {
 
   const TTEntry* tte;
   StateInfo st;
@@ -231,12 +233,12 @@ void TranspositionTable::extract_pv(const Position& pos, Move pv[], int pvSize)
   while (pv[ply] != MOVE_NONE)
       p.do_move(pv[ply++], st);
 
-  // Try to add moves from TT until possible
+  // Try to add moves from TT while possible
   while (   (tte = retrieve(p.get_key())) != NULL
          && tte->move() != MOVE_NONE
          && move_is_legal(p, tte->move())
          && (!p.is_draw() || ply < 2)
-         && ply < pvSize)
+         && ply < PLY_MAX)
   {
       pv[ply] = tte->move();
       p.do_move(pv[ply++], st);