]> git.sesse.net Git - stockfish/commitdiff
Allow for higher depths. (#2147)
authorJoost VandeVondele <Joost.VandeVondele@gmail.com>
Wed, 15 May 2019 07:52:27 +0000 (09:52 +0200)
committerMarco Costalba <mcostalba@users.noreply.github.com>
Wed, 15 May 2019 07:52:27 +0000 (09:52 +0200)
High rootDepths, selDepths and generally searches are increasingly
common with long time control games, analysis, and improving hardware.
In this case, depths of MAX_DEPTH/MAX_PLY (128) can be reached,
and the search tree is truncated.

In principle MAX_PLY can be easily increased, except for a technicality
of storing depths in a signed 8 bit int in the TT. This patch increases
MAX_PLY by storing the depth in an unsigned 8 bit, after shifting by the
most negative depth stored in TT (DEPTH_NONE).

No regression at STC:
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 42235 W: 9565 L: 9484 D: 23186
http://tests.stockfishchess.org/tests/view/5cdb35360ebc5925cf0595e1

Verified to reach high depths on
k1b5/1p1p4/pP1Pp3/K2pPp2/1P1p1P2/3P1P2/5P2/8 w - -
info depth 142 seldepth 154 multipv 1 score cp 537 nodes 26740713110 ...

No bench change.

src/tt.cpp
src/tt.h
src/types.h

index 33768ca4117d099e8fc0a46284a14ea803c60195..b8fe7567c569a6a3d633c2d9b086fcd39fafd96d 100644 (file)
@@ -43,14 +43,15 @@ void TTEntry::save(Key k, Value v, bool pv, Bound b, Depth d, Move m, Value ev)
 
   // Overwrite less valuable entries
   if (  (k >> 48) != key16
-      || d / ONE_PLY > depth8 - 4
+      || d / ONE_PLY + 10 > depth8
       || b == BOUND_EXACT)
   {
       key16     = (uint16_t)(k >> 48);
       value16   = (int16_t)v;
       eval16    = (int16_t)ev;
       genBound8 = (uint8_t)(TT.generation8 | uint8_t(pv) << 2 | b);
-      depth8    = (int8_t)(d / ONE_PLY);
+      assert((d - DEPTH_NONE) / ONE_PLY >= 0);
+      depth8    = (uint8_t)((d - DEPTH_NONE) / ONE_PLY);
   }
 }
 
index fefc8e2c29d928a819ac3437a6cea53192dbb2f3..3608b77c4421ba25e469fbc4d69d39299f92ce5c 100644 (file)
--- a/src/tt.h
+++ b/src/tt.h
@@ -40,7 +40,7 @@ struct TTEntry {
   Move  move()  const { return (Move )move16; }
   Value value() const { return (Value)value16; }
   Value eval()  const { return (Value)eval16; }
-  Depth depth() const { return (Depth)(depth8 * int(ONE_PLY)); }
+  Depth depth() const { return (Depth)(depth8 * int(ONE_PLY)) + DEPTH_NONE; }
   bool is_pv() const { return (bool)(genBound8 & 0x4); }
   Bound bound() const { return (Bound)(genBound8 & 0x3); }
   void save(Key k, Value v, bool pv, Bound b, Depth d, Move m, Value ev);
@@ -53,7 +53,7 @@ private:
   int16_t  value16;
   int16_t  eval16;
   uint8_t  genBound8;
-  int8_t   depth8;
+  uint8_t  depth8;
 };
 
 
index 2e36279d51bb8d5c2e355171d84a7c77827f81ab..b0758f437af06f61107eadba71e8a506b67b6f2d 100644 (file)
@@ -101,7 +101,7 @@ typedef uint64_t Key;
 typedef uint64_t Bitboard;
 
 constexpr int MAX_MOVES = 256;
-constexpr int MAX_PLY   = 128;
+constexpr int MAX_PLY   = 246;
 
 /// A move needs 16 bits to be stored
 ///