/// 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);
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)
case KILLERS_S1:
cur = killers;
- end = cur + 2;
+ end = cur + 3;
return;
case QUIETS_1_S1:
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;
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& 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();
Search::Stack* ss;
Depth depth;
Move ttMove;
- MoveStack killers[2];
+ MoveStack killers[3];
Square recaptureSquare;
int captureThreshold, phase;
MoveStack *cur, *end, *endQuiets, *endBadCaptures;
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);
TT.new_search();
Hist.clear();
Gain.clear();
+ Refutation.clear();
PVSize = Options["MultiPV"];
Skill skill(Options["Skill Level"]);
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
// 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++)