]> git.sesse.net Git - stockfish/commitdiff
Simple always overwrite Refutation table
authorJoona Kiiski <joona.kiiski@gmail.com>
Sun, 12 May 2013 20:21:46 +0000 (21:21 +0100)
committerJoona Kiiski <joona.kiiski@gmail.com>
Sun, 12 May 2013 20:21:46 +0000 (21:21 +0100)
src/movepick.cpp
src/movepick.h
src/search.cpp

index 984520a0e893a0fe9fb81ecf07246e0f144c7c71..8019f374bb90884da608bfa3b77d4861f11ec3e2 100644 (file)
@@ -71,7 +71,7 @@ namespace {
 /// move ordering is at the current node.
 
 MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
 /// move ordering is at the current node.
 
 MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
-                       Search::Stack* s, Value beta) : pos(p), Hist(h), depth(d) {
+                       Search::Stack* s, Move refutationMove, Value beta) : pos(p), Hist(h), depth(d) {
 
   assert(d > DEPTH_ZERO);
 
 
   assert(d > DEPTH_ZERO);
 
@@ -89,6 +89,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
 
       killers[0].move = ss->killers[0];
       killers[1].move = ss->killers[1];
 
       killers[0].move = ss->killers[0];
       killers[1].move = ss->killers[1];
+      killers[2].move = refutationMove;
 
       // Consider sligtly negative captures as good if at low depth and far from beta
       if (ss && ss->staticEval < beta - PawnValueMg && d < 3 * ONE_PLY)
 
       // Consider sligtly negative captures as good if at low depth and far from beta
       if (ss && ss->staticEval < beta - PawnValueMg && d < 3 * ONE_PLY)
@@ -237,7 +238,7 @@ void MovePicker::generate_next() {
 
   case KILLERS_S1:
       cur = killers;
 
   case KILLERS_S1:
       cur = killers;
-      end = cur + 2;
+      end = cur + 3;
       return;
 
   case QUIETS_1_S1:
       return;
 
   case QUIETS_1_S1:
@@ -329,7 +330,8 @@ Move MovePicker::next_move<false>() {
           move = (cur++)->move;
           if (   move != ttMove
               && move != killers[0].move
           move = (cur++)->move;
           if (   move != ttMove
               && move != killers[0].move
-              && move != killers[1].move)
+              && move != killers[1].move
+              && move != killers[2].move)
               return move;
           break;
 
               return move;
           break;
 
index 3e472fb6d25b83086f9167a5de70aadb9c217d7c..90475b3512e15dba6939a4fde9fd130305b15eb1 100644 (file)
@@ -61,6 +61,17 @@ private:
 typedef Stats<false> History;
 typedef Stats<true> Gains;
 
 typedef Stats<false> History;
 typedef Stats<true> Gains;
 
+// FIXME: Document me
+struct RefutationTable {
+
+  void clear() { memset(table, 0, sizeof(table)); }
+  void update(Piece p, Square to, Move m) { table[p][to] = m; }
+  Move get(Piece p, Square to) const { return table[p][to]; }
+
+private:
+  Move table[PIECE_NB][SQUARE_NB]; // Mapping: "move A" -> "move B which refutes move A"
+
+};
 
 /// MovePicker class is used to pick one pseudo legal move at a time from the
 /// current position. The most important method is next_move(), which returns a
 
 /// MovePicker class is used to pick one pseudo legal move at a time from the
 /// current position. The most important method is next_move(), which returns a
@@ -74,7 +85,7 @@ class MovePicker {
   MovePicker& operator=(const MovePicker&); // Silence a warning under MSVC
 
 public:
   MovePicker& operator=(const MovePicker&); // Silence a warning under MSVC
 
 public:
-  MovePicker(const Position&, Move, Depth, const History&, Search::Stack*, Value);
+  MovePicker(const Position&, Move, Depth, const History&, Search::Stack*, Move, Value);
   MovePicker(const Position&, Move, Depth, const History&, Square);
   MovePicker(const Position&, Move, const History&, PieceType);
   template<bool SpNode> Move next_move();
   MovePicker(const Position&, Move, Depth, const History&, Square);
   MovePicker(const Position&, Move, const History&, PieceType);
   template<bool SpNode> Move next_move();
@@ -88,7 +99,7 @@ private:
   Search::Stack* ss;
   Depth depth;
   Move ttMove;
   Search::Stack* ss;
   Depth depth;
   Move ttMove;
-  MoveStack killers[2];
+  MoveStack killers[3];
   Square recaptureSquare;
   int captureThreshold, phase;
   MoveStack *cur, *end, *endQuiets, *endBadCaptures;
   Square recaptureSquare;
   int captureThreshold, phase;
   MoveStack *cur, *end, *endQuiets, *endBadCaptures;
index daed19135359406ddfde08e3c5f825b5e918803c..7369ebababc27a494025d24ddf49a32160985ea8 100644 (file)
@@ -88,6 +88,7 @@ namespace {
   Value DrawValue[COLOR_NB];
   History Hist;
   Gains Gain;
   Value DrawValue[COLOR_NB];
   History Hist;
   Gains Gain;
+  RefutationTable Refutation;
 
   template <NodeType NT>
   Value search(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth);
 
   template <NodeType NT>
   Value search(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth);
@@ -305,6 +306,7 @@ namespace {
     TT.new_search();
     Hist.clear();
     Gain.clear();
     TT.new_search();
     Hist.clear();
     Gain.clear();
+    Refutation.clear();
 
     PVSize = Options["MultiPV"];
     Skill skill(Options["Skill Level"]);
 
     PVSize = Options["MultiPV"];
     Skill skill(Options["Skill Level"]);
@@ -764,7 +766,12 @@ namespace {
 
 split_point_start: // At split points actual search starts from here
 
 
 split_point_start: // At split points actual search starts from here
 
-    MovePicker mp(pos, ttMove, depth, Hist, ss, PvNode ? -VALUE_INFINITE : beta);
+    Move prevMove = (ss-1)->currentMove;
+    Square prevSq = to_sq(prevMove);
+    Piece  prevP  = pos.piece_on(prevSq);
+    Move refutationMove = Refutation.get(prevP, prevSq); 
+
+    MovePicker mp(pos, ttMove, depth, Hist, ss, refutationMove, PvNode ? -VALUE_INFINITE : beta);
     CheckInfo ci(pos);
     value = bestValue; // Workaround a bogus 'uninitialized' warning under gcc
     singularExtensionNode =   !RootNode
     CheckInfo ci(pos);
     value = bestValue; // Workaround a bogus 'uninitialized' warning under gcc
     singularExtensionNode =   !RootNode
@@ -1090,6 +1097,7 @@ 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);
             // 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);
+            //Refutation.update(prevP, prevSq, bestMove);
 
             // Decrease history of all the other played non-capture moves
             for (int i = 0; i < playedMoveCount - 1; i++)
 
             // Decrease history of all the other played non-capture moves
             for (int i = 0; i < playedMoveCount - 1; i++)