Skip to content

Commit c7e31d5

Browse files
committed
Simple always overwrite Refutation table
1 parent 818a353 commit c7e31d5

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

src/movepick.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ namespace {
7171
/// move ordering is at the current node.
7272

7373
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
74-
Search::Stack* s, Value beta) : pos(p), Hist(h), depth(d) {
74+
Search::Stack* s, Move refutationMove, Value beta) : pos(p), Hist(h), depth(d) {
7575

7676
assert(d > DEPTH_ZERO);
7777

@@ -89,6 +89,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
8989

9090
killers[0].move = ss->killers[0];
9191
killers[1].move = ss->killers[1];
92+
killers[2].move = refutationMove;
9293

9394
// Consider sligtly negative captures as good if at low depth and far from beta
9495
if (ss && ss->staticEval < beta - PawnValueMg && d < 3 * ONE_PLY)
@@ -237,7 +238,7 @@ void MovePicker::generate_next() {
237238

238239
case KILLERS_S1:
239240
cur = killers;
240-
end = cur + 2;
241+
end = cur + 3;
241242
return;
242243

243244
case QUIETS_1_S1:
@@ -329,7 +330,8 @@ Move MovePicker::next_move<false>() {
329330
move = (cur++)->move;
330331
if ( move != ttMove
331332
&& move != killers[0].move
332-
&& move != killers[1].move)
333+
&& move != killers[1].move
334+
&& move != killers[2].move)
333335
return move;
334336
break;
335337

src/movepick.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,17 @@ struct Stats {
6161
typedef Stats<false> History;
6262
typedef Stats<true> Gains;
6363

64+
// FIXME: Document me
65+
struct RefutationTable {
66+
67+
void clear() { memset(table, 0, sizeof(table)); }
68+
void update(Piece p, Square to, Move m) { table[p][to] = m; }
69+
Move get(Piece p, Square to) const { return table[p][to]; }
70+
71+
private:
72+
Move table[PIECE_NB][SQUARE_NB]; // Mapping: "move A" -> "move B which refutes move A"
73+
74+
};
6475

6576
/// MovePicker class is used to pick one pseudo legal move at a time from the
6677
/// current position. The most important method is next_move(), which returns a
@@ -74,7 +85,7 @@ class MovePicker {
7485
MovePicker& operator=(const MovePicker&); // Silence a warning under MSVC
7586

7687
public:
77-
MovePicker(const Position&, Move, Depth, const History&, Search::Stack*, Value);
88+
MovePicker(const Position&, Move, Depth, const History&, Search::Stack*, Move, Value);
7889
MovePicker(const Position&, Move, Depth, const History&, Square);
7990
MovePicker(const Position&, Move, const History&, PieceType);
8091
template<bool SpNode> Move next_move();
@@ -88,7 +99,7 @@ class MovePicker {
8899
Search::Stack* ss;
89100
Depth depth;
90101
Move ttMove;
91-
MoveStack killers[2];
102+
MoveStack killers[3];
92103
Square recaptureSquare;
93104
int captureThreshold, phase;
94105
MoveStack *cur, *end, *endQuiets, *endBadCaptures;

src/search.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ namespace {
8888
Value DrawValue[COLOR_NB];
8989
History Hist;
9090
Gains Gain;
91+
RefutationTable Refutation;
9192

9293
template <NodeType NT>
9394
Value search(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth);
@@ -305,6 +306,7 @@ namespace {
305306
TT.new_search();
306307
Hist.clear();
307308
Gain.clear();
309+
Refutation.clear();
308310

309311
PVSize = Options["MultiPV"];
310312
Skill skill(Options["Skill Level"]);
@@ -764,7 +766,12 @@ namespace {
764766

765767
split_point_start: // At split points actual search starts from here
766768

767-
MovePicker mp(pos, ttMove, depth, Hist, ss, PvNode ? -VALUE_INFINITE : beta);
769+
Move prevMove = (ss-1)->currentMove;
770+
Square prevSq = to_sq(prevMove);
771+
Piece prevP = pos.piece_on(prevSq);
772+
Move refutationMove = Refutation.get(prevP, prevSq);
773+
774+
MovePicker mp(pos, ttMove, depth, Hist, ss, refutationMove, PvNode ? -VALUE_INFINITE : beta);
768775
CheckInfo ci(pos);
769776
value = bestValue; // Workaround a bogus 'uninitialized' warning under gcc
770777
singularExtensionNode = !RootNode
@@ -1090,6 +1097,7 @@ namespace {
10901097
// Increase history value of the cut-off move
10911098
Value bonus = Value(int(depth) * int(depth));
10921099
Hist.update(pos.piece_moved(bestMove), to_sq(bestMove), bonus);
1100+
//Refutation.update(prevP, prevSq, bestMove);
10931101

10941102
// Decrease history of all the other played non-capture moves
10951103
for (int i = 0; i < playedMoveCount - 1; i++)

0 commit comments

Comments
 (0)