]> git.sesse.net Git - stockfish/commitdiff
Rename Refutation to Countermove
authorMarco Costalba <mcostalba@gmail.com>
Wed, 15 May 2013 18:35:54 +0000 (20:35 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 15 May 2013 18:59:56 +0000 (20:59 +0200)
Use proper naming according to:

http://chessprogramming.wikispaces.com/Countermove+Heuristic

The name of this idea is "Countermove Heuristic" and was
first introduced by Jos Uiterwijk in 1992

No functional change.

src/movepick.cpp
src/movepick.h
src/search.cpp

index e350bda839b7a073a6775669ee6fac773921d6b4..c75526cc81b8b4989ca22fad6c54b3b5178a2c18 100644 (file)
@@ -70,8 +70,8 @@ namespace {
 /// search captures, promotions and some checks) and about how important good
 /// move ordering is at the current node.
 
-MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h, const Refutations& r,
-                       Search::Stack* s, Value beta) : pos(p), Hist(h), depth(d) {
+MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats& h, const CountermovesStats& cm,
+                       Search::Stack* s, Value beta) : pos(p), history(h), depth(d) {
 
   assert(d > DEPTH_ZERO);
 
@@ -90,7 +90,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h, c
       killers[0].move = ss->killers[0];
       killers[1].move = ss->killers[1];
       Square prevSq = to_sq((ss-1)->currentMove);
-      killers[2].move = r[pos.piece_on(prevSq)][prevSq];
+      killers[2].move = cm[pos.piece_on(prevSq)][prevSq];
 
       // Consider sligtly negative captures as good if at low depth and far from beta
       if (ss && ss->staticEval < beta - PawnValueMg && d < 3 * ONE_PLY)
@@ -105,8 +105,8 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h, c
   end += (ttMove != MOVE_NONE);
 }
 
-MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
-                       Square sq) : pos(p), Hist(h), cur(moves), end(moves) {
+MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats& h,
+                       Square sq) : pos(p), history(h), cur(moves), end(moves) {
 
   assert(d <= DEPTH_ZERO);
 
@@ -137,8 +137,8 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
   end += (ttMove != MOVE_NONE);
 }
 
-MovePicker::MovePicker(const Position& p, Move ttm, const History& h, PieceType pt)
-                       : pos(p), Hist(h), cur(moves), end(moves) {
+MovePicker::MovePicker(const Position& p, Move ttm, const HistoryStats& h, PieceType pt)
+                       : pos(p), history(h), cur(moves), end(moves) {
 
   assert(!pos.checkers());
 
@@ -196,7 +196,7 @@ void MovePicker::score<QUIETS>() {
   for (MoveStack* it = moves; it != end; ++it)
   {
       m = it->move;
-      it->score = Hist[pos.piece_moved(m)][to_sq(m)];
+      it->score = history[pos.piece_moved(m)][to_sq(m)];
   }
 }
 
@@ -212,13 +212,13 @@ void MovePicker::score<EVASIONS>() {
   {
       m = it->move;
       if ((seeScore = pos.see_sign(m)) < 0)
-          it->score = seeScore - History::Max; // At the bottom
+          it->score = seeScore - HistoryStats::Max; // At the bottom
 
       else if (pos.is_capture(m))
           it->score =  PieceValue[MG][pos.piece_on(to_sq(m))]
-                     - type_of(pos.piece_moved(m)) + History::Max;
+                     - type_of(pos.piece_moved(m)) + HistoryStats::Max;
       else
-          it->score = Hist[pos.piece_moved(m)][to_sq(m)];
+          it->score = history[pos.piece_moved(m)][to_sq(m)];
   }
 }
 
index acb57b2e7a4d9fa2260cda3bde57ac8959a7747c..fe9e5a7c08ab31f1b58882354054515e49688dd9 100644 (file)
 
 
 /// The Stats struct stores moves statistics. According to the template parameter
-/// the class can store History, Gains and Refutations statistics. History records
-/// how often different moves have been successful or unsuccessful during the
-/// current search and is used for reduction and move ordering decisions. Gains
-/// records the move's best evaluation gain from one ply to the next and is used
-/// for pruning decisions. Refutations store the move that refute a previous one.
-/// Entries are stored according only to moving piece and destination square, in
-/// particular two moves with different origin but same destination and same piece
-/// will be considered identical.
+/// the class can store History, Gains and Countermoves. History records how often
+/// different moves have been successful or unsuccessful during the current search
+/// and is used for reduction and move ordering decisions. Gains records the move's
+/// best evaluation gain from one ply to the next and is used for pruning decisions.
+/// Countermoves store the move that refute a previous one. Entries are stored
+/// according only to moving piece and destination square, hence two moves with
+/// different origin but same destination and piece will be considered identical.
 template<bool Gain, typename T>
 struct Stats {
 
@@ -60,9 +59,9 @@ private:
   T table[PIECE_NB][SQUARE_NB];
 };
 
-typedef Stats<true, Value> Gains;
-typedef Stats<false, Value> History;
-typedef Stats<false, Move> Refutations;
+typedef Stats< true, Value> GainsStats;
+typedef Stats<false, Value> HistoryStats;
+typedef Stats<false,  Move> CountermovesStats;
 
 
 /// MovePicker class is used to pick one pseudo legal move at a time from the
@@ -77,9 +76,11 @@ class MovePicker {
   MovePicker& operator=(const MovePicker&); // Silence a warning under MSVC
 
 public:
-  MovePicker(const Position&, Move, Depth, const History&, const Refutations&, Search::Stack*, Value);
-  MovePicker(const Position&, Move, Depth, const History&, Square);
-  MovePicker(const Position&, Move, const History&, PieceType);
+  MovePicker(const Position&, Move, Depth, const HistoryStats&, Square);
+  MovePicker(const Position&, Move, const HistoryStats&, PieceType);
+  MovePicker(const Position&, Move, Depth, const HistoryStats&,
+             const CountermovesStats&, Search::Stack*, Value);
+
   template<bool SpNode> Move next_move();
 
 private:
@@ -87,7 +88,7 @@ private:
   void generate_next();
 
   const Position& pos;
-  const History& Hist;
+  const HistoryStats& history;
   Search::Stack* ss;
   Depth depth;
   Move ttMove;
index 2218336775cb8fc58ead6028efd840f60d050c64..238631fabaef6bb4d0f621ed21203f906358aed4 100644 (file)
@@ -86,9 +86,9 @@ namespace {
   TimeManager TimeMgr;
   int BestMoveChanges;
   Value DrawValue[COLOR_NB];
-  History Hist;
-  Gains Gain;
-  Refutations Refutation;
+  HistoryStats History;
+  GainsStats Gains;
+  CountermovesStats Countermoves;
 
   template <NodeType NT>
   Value search(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth);
@@ -304,9 +304,9 @@ namespace {
     bestValue = delta = -VALUE_INFINITE;
     ss->currentMove = MOVE_NULL; // Hack to skip update gains
     TT.new_search();
-    Hist.clear();
-    Gain.clear();
-    Refutation.clear();
+    History.clear();
+    Gains.clear();
+    Countermoves.clear();
 
     PVSize = Options["MultiPV"];
     Skill skill(Options["Skill Level"]);
@@ -623,7 +623,7 @@ namespace {
         &&  type_of(move) == NORMAL)
     {
         Square to = to_sq(move);
-        Gain.update(pos.piece_on(to), to, -(ss-1)->staticEval - ss->staticEval);
+        Gains.update(pos.piece_on(to), to, -(ss-1)->staticEval - ss->staticEval);
     }
 
     // Step 6. Razoring (is omitted in PV nodes)
@@ -734,7 +734,7 @@ namespace {
         assert((ss-1)->currentMove != MOVE_NONE);
         assert((ss-1)->currentMove != MOVE_NULL);
 
-        MovePicker mp(pos, ttMove, Hist, pos.captured_piece_type());
+        MovePicker mp(pos, ttMove, History, pos.captured_piece_type());
         CheckInfo ci(pos);
 
         while ((move = mp.next_move<false>()) != MOVE_NONE)
@@ -766,7 +766,7 @@ namespace {
 
 split_point_start: // At split points actual search starts from here
 
-    MovePicker mp(pos, ttMove, depth, Hist, Refutation, ss, PvNode ? -VALUE_INFINITE : beta);
+    MovePicker mp(pos, ttMove, depth, History, Countermoves, ss, PvNode ? -VALUE_INFINITE : beta);
     CheckInfo ci(pos);
     value = bestValue; // Workaround a bogus 'uninitialized' warning under gcc
     singularExtensionNode =   !RootNode
@@ -884,7 +884,7 @@ split_point_start: // At split points actual search starts from here
           // but fixing this made program slightly weaker.
           Depth predictedDepth = newDepth - reduction<PvNode>(depth, moveCount);
           futilityValue =  ss->staticEval + ss->evalMargin + futility_margin(predictedDepth, moveCount)
-                         + Gain[pos.piece_moved(move)][to_sq(move)];
+                         + Gains[pos.piece_moved(move)][to_sq(move)];
 
           if (futilityValue < beta)
           {
@@ -1091,18 +1091,18 @@ split_point_start: // At split points actual search starts from here
 
             // Increase history value of the cut-off move
             Value bonus = Value(int(depth) * int(depth));
-            Hist.update(pos.piece_moved(bestMove), to_sq(bestMove), bonus);
+            History.update(pos.piece_moved(bestMove), to_sq(bestMove), bonus);
             if (is_ok((ss-1)->currentMove))
             {
                 Square prevSq = to_sq((ss-1)->currentMove);
-                Refutation.update(pos.piece_on(prevSq), prevSq, bestMove);
+                Countermoves.update(pos.piece_on(prevSq), prevSq, bestMove);
             }
 
             // Decrease history of all the other played non-capture moves
             for (int i = 0; i < playedMoveCount - 1; i++)
             {
                 Move m = movesSearched[i];
-                Hist.update(pos.piece_moved(m), to_sq(m), -bonus);
+                History.update(pos.piece_moved(m), to_sq(m), -bonus);
             }
         }
     }
@@ -1215,7 +1215,7 @@ split_point_start: // At split points actual search starts from here
     // to search the moves. Because the depth is <= 0 here, only captures,
     // queen promotions and checks (only if depth >= DEPTH_QS_CHECKS) will
     // be generated.
-    MovePicker mp(pos, ttMove, depth, Hist, to_sq((ss-1)->currentMove));
+    MovePicker mp(pos, ttMove, depth, History, to_sq((ss-1)->currentMove));
     CheckInfo ci(pos);
 
     // Loop through the moves until no moves remain or a beta cutoff occurs