From c7e31d5aa8e7b51f6580dc0c2a51e2aee15eb817 Mon Sep 17 00:00:00 2001 From: Joona Kiiski Date: Sun, 12 May 2013 21:21:46 +0100 Subject: [PATCH] Simple always overwrite Refutation table --- src/movepick.cpp | 8 +++++--- src/movepick.h | 15 +++++++++++++-- src/search.cpp | 10 +++++++++- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/movepick.cpp b/src/movepick.cpp index 984520a0..8019f374 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -71,7 +71,7 @@ namespace { /// 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); @@ -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[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) @@ -237,7 +238,7 @@ void MovePicker::generate_next() { case KILLERS_S1: cur = killers; - end = cur + 2; + end = cur + 3; return; case QUIETS_1_S1: @@ -329,7 +330,8 @@ Move MovePicker::next_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; diff --git a/src/movepick.h b/src/movepick.h index 3e472fb6..90475b35 100644 --- a/src/movepick.h +++ b/src/movepick.h @@ -61,6 +61,17 @@ private: typedef Stats History; typedef Stats 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 @@ -74,7 +85,7 @@ class MovePicker { 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 Move next_move(); @@ -88,7 +99,7 @@ private: Search::Stack* ss; Depth depth; Move ttMove; - MoveStack killers[2]; + MoveStack killers[3]; Square recaptureSquare; int captureThreshold, phase; MoveStack *cur, *end, *endQuiets, *endBadCaptures; diff --git a/src/search.cpp b/src/search.cpp index daed1913..7369ebab 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -88,6 +88,7 @@ namespace { Value DrawValue[COLOR_NB]; History Hist; Gains Gain; + RefutationTable Refutation; template Value search(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth); @@ -305,6 +306,7 @@ namespace { TT.new_search(); Hist.clear(); Gain.clear(); + Refutation.clear(); PVSize = Options["MultiPV"]; Skill skill(Options["Skill Level"]); @@ -764,7 +766,12 @@ namespace { 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 @@ -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); + //Refutation.update(prevP, prevSq, bestMove); // Decrease history of all the other played non-capture moves for (int i = 0; i < playedMoveCount - 1; i++) -- 2.39.2