]> git.sesse.net Git - stockfish/commitdiff
Merge Joona's razoring tweaks
authorMarco Costalba <mcostalba@gmail.com>
Tue, 28 Apr 2009 06:51:11 +0000 (08:51 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Tue, 28 Apr 2009 07:00:09 +0000 (09:00 +0200)
After proof testing on 3 different engines these
are the results:

Stockfish - Toga II 1.4.1SE +130 -132 =132 49.75%
Stockfish - Deep Sieng 3.0  +145 -110 =150 54.45%
Stockfish - HIARCS 12 MP    +94  -149 =150 43.00%

So it seems no regressions occurs, although also no
improvment. But anyhow this patch increases Stockfish
strenght against itself, so merge it.

Note that this patch not only adds back razoring at depth
one, but also increases razor depth limit from 3 to 4
because hard coded depth 4 limit is no more overwritten
by UCI parameter that otherwise defaults to 3.

src/direction.h
src/misc.cpp
src/misc.h
src/piece.cpp
src/position.cpp
src/position.h
src/search.cpp
src/timeoday.cpp [deleted file]
src/tt.cpp
src/tt.h
src/ucioption.cpp

index 4ca264a0291ae5ed59deb21a7170444fcadab32b..1890f1cff7035832c390f6fc626ef36c97ff4c96 100644 (file)
@@ -74,6 +74,13 @@ inline SignedDirection signed_direction_between_squares(Square s1, Square s2) {
   return SignedDirection(SignedDirectionTable[s1][s2]);
 }
 
+inline int direction_is_diagonal(Square s1, Square s2) {
+  return DirectionTable[s1][s2] & 2;
+}
+
+inline bool direction_is_straight(Square s1, Square s2) {
+  return DirectionTable[s1][s2] < 2;
+}
 
 ////
 //// Prototypes
index 68f6103c651b0d467072edcd15812939fead7f44..281d8595a7cca6dd227fe6c0f83b1cb7610beb04 100644 (file)
 #  include <unistd.h>
 
 #else
+/*
+   (c) Copyright 1992 Eric Backus
 
+   This software may be used freely so long as this copyright notice is
+   left intact. There is no warrantee on this software.
+*/
 #  include <windows.h>
 #  include <time.h>
 #  include "dos.h"
-int gettimeofday(struct timeval * tp, struct timezone * tzp);
+static int gettimeofday(struct timeval* tp, struct timezone*)
+{
+    SYSTEMTIME systime;
+
+    if (tp)
+    {
+        struct tm tmrec;
+        time_t theTime = time(NULL);
+
+        tmrec = *localtime(&theTime);
+        tp->tv_sec = mktime(&tmrec);
+        GetLocalTime(&systime); /* system time */
+
+        tp->tv_usec = systime.wMilliseconds * 1000;
+    }
+    return 0;
+}
 
 #endif
 
@@ -45,14 +66,20 @@ int gettimeofday(struct timeval * tp, struct timezone * tzp);
 
 #include "misc.h"
 
+using namespace std;
+
+/// Version number. If this is left empty, the current date (in the format
+/// YYMMDD) is used as a version number.
+
+static const string EngineVersion = "";
+static const string AppName = "Stockfish";
+static const string AppTag  = "";
+
 
 ////
 //// Variables
 ////
 
-static const std::string AppName = "Stockfish";
-static const std::string AppTag  = "";
-
 long dbg_cnt0 = 0;
 long dbg_cnt1 = 0;
 
@@ -103,28 +130,26 @@ void dbg_mean_of(int v) {
 
 void dbg_print_hit_rate() {
 
-  std::cout << "Total " << dbg_cnt0 << " Hit " << dbg_cnt1
-            << " hit rate (%) " << (dbg_cnt1*100)/(dbg_cnt0 ? dbg_cnt0 : 1)
-            << std::endl;
+  cout << "Total " << dbg_cnt0 << " Hit " << dbg_cnt1
+       << " hit rate (%) " << (dbg_cnt1*100)/(dbg_cnt0 ? dbg_cnt0 : 1) << endl;
 }
 
 void dbg_print_mean() {
 
-  std::cout << "Total " << dbg_cnt0 << " Mean "
-            << (float)dbg_cnt1 / (dbg_cnt0 ? dbg_cnt0 : 1) << std::endl;
+  cout << "Total " << dbg_cnt0 << " Mean "
+       << (float)dbg_cnt1 / (dbg_cnt0 ? dbg_cnt0 : 1) << endl;
 }
 
-void dbg_print_hit_rate(std::ofstream& logFile) {
+void dbg_print_hit_rate(ofstream& logFile) {
 
   logFile << "Total " << dbg_cnt0 << " Hit " << dbg_cnt1
-          << " hit rate (%) " << (dbg_cnt1*100)/(dbg_cnt0 ? dbg_cnt0 : 1)
-          << std::endl;
+          << " hit rate (%) " << (dbg_cnt1*100)/(dbg_cnt0 ? dbg_cnt0 : 1) << endl;
 }
 
-void dbg_print_mean(std::ofstream& logFile) {
+void dbg_print_mean(ofstream& logFile) {
 
   logFile << "Total " << dbg_cnt0 << " Mean "
-          << (float)dbg_cnt1 / (dbg_cnt0 ? dbg_cnt0 : 1) << std::endl;
+          << (float)dbg_cnt1 / (dbg_cnt0 ? dbg_cnt0 : 1) << endl;
 }
 
 /// engine_name() returns the full name of the current Stockfish version.
@@ -132,26 +157,25 @@ void dbg_print_mean(std::ofstream& logFile) {
 /// program was compiled) or "Stockfish <version number>", depending on whether
 /// the constant EngineVersion (defined in misc.h) is empty.
 
-const std::string engine_name() {
+const string engine_name() {
 
-  if (EngineVersion.empty())
-  {
-      std::string date(__DATE__); // From compiler, format is "Sep 21 2008"
-      std::string months("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec");
+  if (!EngineVersion.empty())
+      return "Stockfish " + EngineVersion;
 
-      size_t mon = 1 + months.find(date.substr(0, 3)) / 4;
+  string date(__DATE__); // From compiler, format is "Sep 21 2008"
+  string months("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec");
 
-      std::stringstream s;
-      std::string day = (date[4] == ' ' ? date.substr(5, 1) : date.substr(4, 2));
+  size_t mon = 1 + months.find(date.substr(0, 3)) / 4;
 
-      std::string name = AppName + " " + AppTag + " ";
+  stringstream s;
+  string day = (date[4] == ' ' ? date.substr(5, 1) : date.substr(4, 2));
 
-      s << name << date.substr(date.length() - 2) << std::setfill('0')
-        << std::setw(2) << mon << std::setw(2) << day;
+  string name = AppName + " " + AppTag + " ";
 
-      return s.str();
-  } else
-      return "Stockfish " + EngineVersion;
+  s << name << date.substr(date.length() - 2) << setfill('0')
+    << setw(2) << mon << setw(2) << day;
+
+  return s.str();
 }
 
 
index 0e656cb2b0d08c11f99f1f89f01c0ac8fe7ae52e..aff7cf3e1e0aca0703f95e3d8d5ec97b5f0d450e 100644 (file)
 #include <string>
 
 
-////
-//// Constants
-////
-
-
-/// Version number.  If this is left empty, the current date (in the format
-/// YYMMDD) is used as a version number.
-
-const std::string EngineVersion = "";
-
-
 ////
 //// Macros
 ////
index 40babba695165c8ac7630f1e9b0c0222746308ea..84ed22d78dd47740fcffa34a0d51620f748a7c0b 100644 (file)
 //// Includes
 ////
 
-#include <cstring>
+#include <string>
 
 #include "piece.h"
 
+using namespace std;
 
 ////
 //// Functions
 
 /// Translating piece types to/from English piece letters
 
-static const char PieceChars[] = " pnbrqk";
+static const string PieceChars(" pnbrqk PNBRQK");
 
 char piece_type_to_char(PieceType pt, bool upcase) {
-  return char(upcase? toupper(PieceChars[pt]) : PieceChars[pt]);
+
+  return PieceChars[pt + upcase * 7];
 }
 
 PieceType piece_type_from_char(char c) {
-  const char* ch = strchr(PieceChars, tolower(c));
-  return ch? PieceType(ch - PieceChars) : NO_PIECE_TYPE;
+
+  size_t idx = PieceChars.find(c);
+
+  return idx != string::npos ? PieceType(idx % 7) : NO_PIECE_TYPE;
 }
index abe75807e2869044b05aad7b1cdfd696c31594bf..5a42792eb8a97bc105883a0436cf6cc42f903de5 100644 (file)
@@ -599,19 +599,17 @@ bool Position::move_is_check(Move m, Bitboard dcCandidates) const {
 
   case BISHOP:
     return   (dcCandidates && bit_is_set(dcCandidates, from))
-          || (   direction_between_squares(ksq, to) != DIR_NONE
-              && bit_is_set(piece_attacks<BISHOP>(ksq), to));
+          || (direction_is_diagonal(ksq, to) && bit_is_set(piece_attacks<BISHOP>(ksq), to));
 
   case ROOK:
     return   (dcCandidates && bit_is_set(dcCandidates, from))
-          || (   direction_between_squares(ksq, to) != DIR_NONE
-              && bit_is_set(piece_attacks<ROOK>(ksq), to));
+          || (direction_is_straight(ksq, to) && bit_is_set(piece_attacks<ROOK>(ksq), to));
 
   case QUEEN:
       // Discovered checks are impossible!
       assert(!bit_is_set(dcCandidates, from));
-      return (   direction_between_squares(ksq, to) != DIR_NONE
-              && bit_is_set(piece_attacks<QUEEN>(ksq), to));
+      return (   (direction_is_straight(ksq, to) && bit_is_set(piece_attacks<ROOK>(ksq), to))
+              || (direction_is_diagonal(ksq, to) && bit_is_set(piece_attacks<BISHOP>(ksq), to)));
 
   case KING:
       // Discovered check?
@@ -651,20 +649,6 @@ bool Position::move_is_check(Move m, Bitboard dcCandidates) const {
 }
 
 
-/// Position::move_is_capture() tests whether a move from the current
-/// position is a capture. Move must not be MOVE_NONE.
-
-bool Position::move_is_capture(Move m) const {
-
-  assert(m != MOVE_NONE);
-
-  return (   !square_is_empty(move_to(m))
-          && (color_of_piece_on(move_to(m)) != color_of_piece_on(move_from(m)))
-         )
-         || move_is_ep(m);
-}
-
-
 /// Position::update_checkers() udpates chekers info given the move. It is called
 /// in do_move() and is faster then find_checkers().
 
index d2b37478e4ce681714fc11b654986da82a016209..65bfa25807f4eb2af0ac95a3565f589ae18c5ec5 100644 (file)
@@ -718,5 +718,14 @@ inline bool Position::has_pawn_on_7th(Color c) const {
   return pawns(c) & relative_rank_bb(c, RANK_7);
 }
 
+inline bool Position::move_is_capture(Move m) const {
+
+  // Move must not be MOVE_NONE !
+
+  return (   !square_is_empty(move_to(m))
+          && (color_of_piece_on(move_to(m)) != color_of_piece_on(move_from(m)))
+         )
+         || move_is_ep(m);
+}
 
 #endif // !defined(POSITION_H_INCLUDED)
index 4e5103f035fceb52253d00a739c701114999323a..3ad5423d9d41a7f4600dc97cce32bed306514b2c 100644 (file)
@@ -139,7 +139,7 @@ namespace {
   Depth ThreatDepth;
 
   // Depth limit for selective search
-  Depth SelectiveDepth;
+  const Depth SelectiveDepth = 7*OnePly;
 
   // Use internal iterative deepening?
   const bool UseIIDAtPVNodes = true;
@@ -321,7 +321,7 @@ namespace {
 ////
 
 // The main transposition table
-TranspositionTable TT = TranspositionTable(TTDefaultSize);
+TranspositionTable TT;
 
 
 // Number of active threads:
@@ -432,7 +432,6 @@ void think(const Position &pos, bool infinite, bool ponder, int side_to_move,
   LMRPVMoves     = get_option_value_int("Full Depth Moves (PV nodes)") + 1;
   LMRNonPVMoves  = get_option_value_int("Full Depth Moves (non-PV nodes)") + 1;
   ThreatDepth    = get_option_value_int("Threat Depth") * OnePly;
-  SelectiveDepth = get_option_value_int("Selective Plies") * OnePly;
 
   Chess960 = get_option_value_bool("UCI_Chess960");
   ShowCurrentLine = get_option_value_bool("UCI_ShowCurrLine");
@@ -1189,7 +1188,7 @@ namespace {
         return bestValue;
 
     if (bestValue <= oldAlpha)
-        TT.store(pos, value_to_tt(bestValue, ply), depth, MOVE_NONE, VALUE_TYPE_UPPER);
+        TT.store(pos, value_to_tt(bestValue, ply), VALUE_TYPE_UPPER, depth, MOVE_NONE);
 
     else if (bestValue >= beta)
     {
@@ -1200,10 +1199,10 @@ namespace {
             update_history(pos, m, depth, movesSearched, moveCount);
             update_killers(m, ss[ply]);
         }
-        TT.store(pos, value_to_tt(bestValue, ply), depth, m, VALUE_TYPE_LOWER);
+        TT.store(pos, value_to_tt(bestValue, ply), VALUE_TYPE_LOWER, depth, m);
     }
     else
-        TT.store(pos, value_to_tt(bestValue, ply), depth, ss[ply].pv[ply], VALUE_TYPE_EXACT);
+        TT.store(pos, value_to_tt(bestValue, ply), VALUE_TYPE_EXACT, depth, ss[ply].pv[ply]);
 
     return bestValue;
   }
@@ -1370,7 +1369,7 @@ namespace {
               continue;
 
           // Value based pruning
-          if (depth < 7 * OnePly && approximateEval < beta)
+          if (approximateEval < beta)
           {
               if (futilityValue == VALUE_NONE)
                   futilityValue =  evaluate(pos, ei, threadID)
@@ -1449,7 +1448,7 @@ namespace {
         return bestValue;
 
     if (bestValue < beta)
-        TT.store(pos, value_to_tt(bestValue, ply), depth, MOVE_NONE, VALUE_TYPE_UPPER);
+        TT.store(pos, value_to_tt(bestValue, ply), VALUE_TYPE_UPPER, depth, MOVE_NONE);
     else
     {
         BetaCounter.add(pos.side_to_move(), depth, threadID);
@@ -1459,7 +1458,7 @@ namespace {
             update_history(pos, m, depth, movesSearched, moveCount);
             update_killers(m, ss[ply]);
         }
-        TT.store(pos, value_to_tt(bestValue, ply), depth, m, VALUE_TYPE_LOWER);
+        TT.store(pos, value_to_tt(bestValue, ply), VALUE_TYPE_LOWER, depth, m);
     }
 
     assert(bestValue > -VALUE_INFINITE && bestValue < VALUE_INFINITE);
@@ -1538,7 +1537,7 @@ namespace {
     {
         // Store the score to avoid a future costly evaluation() call
         if (!isCheck && !tte && ei.futilityMargin == 0)
-            TT.store(pos, value_to_tt(bestValue, ply), Depth(-127*OnePly), MOVE_NONE, VALUE_TYPE_EVAL);
+            TT.store(pos, value_to_tt(bestValue, ply), VALUE_TYPE_EVAL, Depth(-127*OnePly), MOVE_NONE);
 
         return bestValue;
     }
@@ -1631,9 +1630,9 @@ namespace {
     {
         Depth d = (depth == Depth(0) ? Depth(0) : Depth(-1));
         if (bestValue < beta)
-            TT.store(pos, value_to_tt(bestValue, ply), d, MOVE_NONE, VALUE_TYPE_UPPER);
+            TT.store(pos, value_to_tt(bestValue, ply), VALUE_TYPE_UPPER, d, MOVE_NONE);
         else
-            TT.store(pos, value_to_tt(bestValue, ply), d, m, VALUE_TYPE_LOWER);
+            TT.store(pos, value_to_tt(bestValue, ply), VALUE_TYPE_LOWER, d, m);
     }
 
     // Update killers only for good check moves
diff --git a/src/timeoday.cpp b/src/timeoday.cpp
deleted file mode 100644 (file)
index 6909c2d..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
-   (c) Copyright 1992 Eric Backus
-
-   This software may be used freely so long as this copyright notice is
-   left intact. There is no warrantee on this software.
-*/
-
-#include <windows.h>
-#include <time.h>
-#include "dos.h"
-
-int gettimeofday(struct timeval* tp, struct timezone*)
-{
-    SYSTEMTIME systime;
-
-    if (tp)
-    {
-        struct tm tmrec;
-        time_t theTime = time(NULL);
-
-        tmrec = *localtime(&theTime);
-        tp->tv_sec = mktime(&tmrec);
-        GetLocalTime(&systime); /* system time */
-
-        tp->tv_usec = systime.wMilliseconds * 1000;
-    }
-    return 0;
-}
index 8c5f3e347a5353756868e8a2c0877774015647f6..fe222106f9a67f59caedcbcc66a80e13293a90c3 100644 (file)
 //// Functions
 ////
 
-/// Constructor
+TranspositionTable::TranspositionTable() {
 
-TranspositionTable::TranspositionTable(unsigned mbSize) {
-
-  size = 0;
-  generation = 0;
-  writes = 0;
+  size = writes = 0;
   entries = 0;
-  set_size(mbSize);
+  generation = 0;
 }
 
-
-/// Destructor
-
 TranspositionTable::~TranspositionTable() {
 
   delete [] entries;
@@ -58,33 +51,33 @@ TranspositionTable::~TranspositionTable() {
 
 void TranspositionTable::set_size(unsigned mbSize) {
 
-  assert(mbSize >= 4 && mbSize <= 1024);
+  assert(mbSize >= 4 && mbSize <= 4096);
 
   unsigned newSize = 1024;
 
   // We store a cluster of 4 TTEntry for each position and newSize is
   // the maximum number of storable positions
-  for ( ; newSize * 4 * (sizeof(TTEntry)) <= (mbSize << 20); newSize *= 2);
-  newSize /= 2;
+  while ((2 * newSize) * 4 * (sizeof(TTEntry)) <= (mbSize << 20))
+      newSize *= 2;
+
   if (newSize != size)
   {
-    size = newSize;
-    delete [] entries;
-    entries = new TTEntry[size * 4];
-    if (!entries)
-    {
-      std::cerr << "Failed to allocate " << mbSize
-                << " MB for transposition table."
-                << std::endl;
-      exit(EXIT_FAILURE);
-    }
-    clear();
+      size = newSize;
+      delete [] entries;
+      entries = new TTEntry[size * 4];
+      if (!entries)
+      {
+          std::cerr << "Failed to allocate " << mbSize
+                    << " MB for transposition table." << std::endl;
+          exit(EXIT_FAILURE);
+      }
+      clear();
   }
 }
 
 
 /// TranspositionTable::clear overwrites the entire transposition table
-/// with zeroes.  It is called whenever the table is resized, or when the
+/// with zeroes. It is called whenever the table is resized, or when the
 /// user asks the program to clear the table (from the UCI interface).
 /// Perhaps we should also clear it when the "ucinewgame" command is recieved?
 
@@ -96,45 +89,44 @@ void TranspositionTable::clear() {
 
 /// TranspositionTable::store writes a new entry containing a position,
 /// a value, a value type, a search depth, and a best move to the
-/// transposition table.  The transposition table is organized in clusters
-/// of four TTEntry objects, and when a new entry is written, it replaces
-/// the least valuable of the four entries in a cluster.  A TTEntry t1 is
+/// transposition table. Transposition table is organized in clusters of
+/// four TTEntry objects, and when a new entry is written, it replaces
+/// the least valuable of the four entries in a cluster. A TTEntry t1 is
 /// considered to be more valuable than a TTEntry t2 if t1 is from the
 /// current search and t2 is from a previous search, or if the depth of t1
 /// is bigger than the depth of t2. A TTEntry of type VALUE_TYPE_EVAL
 /// never replaces another entry for the same position.
 
-void TranspositionTable::store(const Position &pos, Value v, Depth d,
-                               Move m, ValueType type) {
+void TranspositionTable::store(const Position& p, Value v, ValueType t, Depth d, Move m) {
+
   TTEntry *tte, *replace;
 
-  tte = replace = first_entry(pos);
+  tte = replace = first_entry(p);
   for (int i = 0; i < 4; i++, tte++)
   {
-    if (!tte->key() || tte->key() == pos.get_key()) // empty or overwrite old
-    {
-        // Do not overwrite position entry when VALUE_TYPE_EVAL
-        if (   tte->key()
-            && type == VALUE_TYPE_EVAL)
-            return;
-
-        if (m == MOVE_NONE)
-            m = tte->move();
-
-        *tte = TTEntry(pos.get_key(), v, type, d, m, generation);
-        return;
-    }
-    else if (i == 0)  // replace would be a no-op in this common case
-        continue;
-
-    int c1 = (replace->generation() == generation ?  2 : 0);
-    int c2 = (tte->generation() == generation ? -2 : 0);
-    int c3 = (tte->depth() < replace->depth() ?  1 : 0);
-
-    if (c1 + c2 + c3 > 0)
-        replace = tte;
+      if (!tte->key() || tte->key() == p.get_key()) // empty or overwrite old
+      {
+          // Do not overwrite when new type is VALUE_TYPE_EVAL
+          if (tte->key() && t == VALUE_TYPE_EVAL)
+              return;
+
+          if (m == MOVE_NONE)
+              m = tte->move();
+
+          *tte = TTEntry(p.get_key(), v, t, d, m, generation);
+          return;
+      }
+      else if (i == 0)  // replace would be a no-op in this common case
+          continue;
+
+      int c1 = (replace->generation() == generation ?  2 : 0);
+      int c2 = (tte->generation() == generation ? -2 : 0);
+      int c3 = (tte->depth() < replace->depth() ?  1 : 0);
+
+      if (c1 + c2 + c3 > 0)
+          replace = tte;
   }
-  *replace = TTEntry(pos.get_key(), v, type, d, m, generation);
+  *replace = TTEntry(p.get_key(), v, t, d, m, generation);
   writes++;
 }
 
@@ -143,15 +135,14 @@ void TranspositionTable::store(const Position &pos, Value v, Depth d,
 /// transposition table. Returns a pointer to the TTEntry or NULL
 /// if position is not found.
 
-TTEntry* TranspositionTable::retrieve(const Position &pos) const {
+TTEntry* TranspositionTable::retrieve(const Positionpos) const {
 
   TTEntry *tte = first_entry(pos);
 
   for (int i = 0; i < 4; i++, tte++)
-  {
       if (tte->key() == pos.get_key())
           return tte;
-  }
+
   return NULL;
 }
 
@@ -159,13 +150,13 @@ TTEntry* TranspositionTable::retrieve(const Position &pos) const {
 /// TranspositionTable::first_entry returns a pointer to the first
 /// entry of a cluster given a position.
 
-inline TTEntry* TranspositionTable::first_entry(const Position &pos) const {
+inline TTEntry* TranspositionTable::first_entry(const Positionpos) const {
 
   return entries + (int(pos.get_key() & (size - 1)) << 2);
 }
 
 /// TranspositionTable::new_search() is called at the beginning of every new
-/// search.  It increments the "generation" variable, which is used to
+/// search. It increments the "generation" variable, which is used to
 /// distinguish transposition table entries from previous searches from
 /// entries from the current search.
 
@@ -177,19 +168,19 @@ void TranspositionTable::new_search() {
 
 
 /// TranspositionTable::insert_pv() is called at the end of a search
-/// iteration, and inserts the PV back into the PV.  This makes sure the
-/// old PV moves are searched first, even if the old TT entries have been
-/// overwritten.
+/// iteration, and inserts the PV back into the PV. This makes sure
+/// the old PV moves are searched first, even if the old TT entries
+/// have been overwritten.
 
-void TranspositionTable::insert_pv(const Position &pos, Move pv[]) {
+void TranspositionTable::insert_pv(const Positionpos, Move pv[]) {
 
   StateInfo st;
   Position p(pos);
 
   for (int i = 0; pv[i] != MOVE_NONE; i++)
   {
-    store(p, VALUE_NONE, Depth(-127*OnePly), pv[i], VALUE_TYPE_NONE);
-    p.do_move(pv[i], st);
+      store(p, VALUE_NONE, VALUE_TYPE_NONE, Depth(-127*OnePly), pv[i]);
+      p.do_move(pv[i], st);
   }
 }
 
@@ -198,19 +189,8 @@ void TranspositionTable::insert_pv(const Position &pos, Move pv[]) {
 /// entries which have received at least one write during the current search.
 /// It is used to display the "info hashfull ..." information in UCI.
 
-int TranspositionTable::full() {
+int TranspositionTable::full() const {
 
   double N = double(size) * 4.0;
   return int(1000 * (1 - exp(writes * log(1.0 - 1.0/N))));
 }
-
-
-/// Constructors
-
-TTEntry::TTEntry() {
-}
-
-TTEntry::TTEntry(Key k, Value v, ValueType t, Depth d, Move m,
-                 int generation) :
-  key_ (k), data((m & 0x1FFFF) | (t << 20) | (generation << 23)),
-  value_(int16_t(v)), depth_(int16_t(d)) {}
index 76ecad81e101254dea4832984f2022dd9e2055da..0918e3e8d3938ff7a3aac7b4859c8f572c910d91 100644 (file)
--- a/src/tt.h
+++ b/src/tt.h
 class TTEntry {
 
 public:
-  TTEntry();
-  TTEntry(Key k, Value v, ValueType t, Depth d, Move m, int generation);
+  TTEntry() {}
+  TTEntry(Key k, Value v, ValueType t, Depth d, Move m, int generation)
+        : key_ (k), data((m & 0x1FFFF) | (t << 20) | (generation << 23)),
+          value_(int16_t(v)), depth_(int16_t(d)) {}
+
   Key key() const { return key_; }
   Depth depth() const { return Depth(depth_); }
   Move move() const { return Move(data & 0x1FFFF); }
@@ -76,32 +79,22 @@ private:
 class TranspositionTable {
 
 public:
-  TranspositionTable(unsigned mbSize);
+  TranspositionTable();
   ~TranspositionTable();
   void set_size(unsigned mbSize);
   void clear();
-  void store(const Position &pos, Value v, Depth d, Move m, ValueType type);
-  TTEntry* retrieve(const Position &pos) const;
+  void store(const Position& pos, Value v, ValueType type, Depth d, Move m);
+  TTEntry* retrieve(const Positionpos) const;
   void new_search();
-  void insert_pv(const Position &pos, Move pv[]);
-  int full();
+  void insert_pv(const Positionpos, Move pv[]);
+  int full() const;
 
 private:
-  inline TTEntry* first_entry(const Position &pos) const;
+  inline TTEntry* first_entry(const Positionpos) const;
 
-  unsigned size;
-  int writes;
+  unsigned size, writes;
   TTEntry* entries;
   uint8_t generation;
 };
 
-
-////
-//// Constants and variables
-////
-
-// Default transposition table size, in megabytes:
-const int TTDefaultSize = 32;
-
-
 #endif // !defined(TT_H_INCLUDED)
index 63c27403356251b4d703f52b825904e74f1a6f6e..442ca924e10761a030213f8a32533ad943509963 100644 (file)
@@ -125,7 +125,6 @@ namespace {
     o["Full Depth Moves (PV nodes)"] = Option(14, 1, 100);
     o["Full Depth Moves (non-PV nodes)"] = Option(3, 1, 100);
     o["Threat Depth"] = Option(5, 0, 100);
-    o["Selective Plies"] = Option(7, 0, 10);
     o["Futility Pruning (Main Search)"] = Option(true);
     o["Futility Pruning (Quiescence Search)"] = Option(true);
     o["LSN filtering"] = Option(true);