Skip to content

Commit 148490f

Browse files
committed
Rename Refutation to Countermove
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.
1 parent 7c6f346 commit 148490f

File tree

3 files changed

+41
-40
lines changed

3 files changed

+41
-40
lines changed

src/movepick.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ namespace {
7070
/// search captures, promotions and some checks) and about how important good
7171
/// move ordering is at the current node.
7272

73-
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h, const Refutations& r,
74-
Search::Stack* s, Value beta) : pos(p), Hist(h), depth(d) {
73+
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats& h, const CountermovesStats& cm,
74+
Search::Stack* s, Value beta) : pos(p), history(h), depth(d) {
7575

7676
assert(d > DEPTH_ZERO);
7777

@@ -90,7 +90,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h, c
9090
killers[0].move = ss->killers[0];
9191
killers[1].move = ss->killers[1];
9292
Square prevSq = to_sq((ss-1)->currentMove);
93-
killers[2].move = r[pos.piece_on(prevSq)][prevSq];
93+
killers[2].move = cm[pos.piece_on(prevSq)][prevSq];
9494

9595
// Consider sligtly negative captures as good if at low depth and far from beta
9696
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
105105
end += (ttMove != MOVE_NONE);
106106
}
107107

108-
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
109-
Square sq) : pos(p), Hist(h), cur(moves), end(moves) {
108+
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats& h,
109+
Square sq) : pos(p), history(h), cur(moves), end(moves) {
110110

111111
assert(d <= DEPTH_ZERO);
112112

@@ -137,8 +137,8 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
137137
end += (ttMove != MOVE_NONE);
138138
}
139139

140-
MovePicker::MovePicker(const Position& p, Move ttm, const History& h, PieceType pt)
141-
: pos(p), Hist(h), cur(moves), end(moves) {
140+
MovePicker::MovePicker(const Position& p, Move ttm, const HistoryStats& h, PieceType pt)
141+
: pos(p), history(h), cur(moves), end(moves) {
142142

143143
assert(!pos.checkers());
144144

@@ -196,7 +196,7 @@ void MovePicker::score<QUIETS>() {
196196
for (MoveStack* it = moves; it != end; ++it)
197197
{
198198
m = it->move;
199-
it->score = Hist[pos.piece_moved(m)][to_sq(m)];
199+
it->score = history[pos.piece_moved(m)][to_sq(m)];
200200
}
201201
}
202202

@@ -212,13 +212,13 @@ void MovePicker::score<EVASIONS>() {
212212
{
213213
m = it->move;
214214
if ((seeScore = pos.see_sign(m)) < 0)
215-
it->score = seeScore - History::Max; // At the bottom
215+
it->score = seeScore - HistoryStats::Max; // At the bottom
216216

217217
else if (pos.is_capture(m))
218218
it->score = PieceValue[MG][pos.piece_on(to_sq(m))]
219-
- type_of(pos.piece_moved(m)) + History::Max;
219+
- type_of(pos.piece_moved(m)) + HistoryStats::Max;
220220
else
221-
it->score = Hist[pos.piece_moved(m)][to_sq(m)];
221+
it->score = history[pos.piece_moved(m)][to_sq(m)];
222222
}
223223
}
224224

src/movepick.h

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,13 @@
3030

3131

3232
/// The Stats struct stores moves statistics. According to the template parameter
33-
/// the class can store History, Gains and Refutations statistics. History records
34-
/// how often different moves have been successful or unsuccessful during the
35-
/// current search and is used for reduction and move ordering decisions. Gains
36-
/// records the move's best evaluation gain from one ply to the next and is used
37-
/// for pruning decisions. Refutations store the move that refute a previous one.
38-
/// Entries are stored according only to moving piece and destination square, in
39-
/// particular two moves with different origin but same destination and same piece
40-
/// will be considered identical.
33+
/// the class can store History, Gains and Countermoves. History records how often
34+
/// different moves have been successful or unsuccessful during the current search
35+
/// and is used for reduction and move ordering decisions. Gains records the move's
36+
/// best evaluation gain from one ply to the next and is used for pruning decisions.
37+
/// Countermoves store the move that refute a previous one. Entries are stored
38+
/// according only to moving piece and destination square, hence two moves with
39+
/// different origin but same destination and piece will be considered identical.
4140
template<bool Gain, typename T>
4241
struct Stats {
4342

@@ -60,9 +59,9 @@ struct Stats {
6059
T table[PIECE_NB][SQUARE_NB];
6160
};
6261

63-
typedef Stats<true, Value> Gains;
64-
typedef Stats<false, Value> History;
65-
typedef Stats<false, Move> Refutations;
62+
typedef Stats< true, Value> GainsStats;
63+
typedef Stats<false, Value> HistoryStats;
64+
typedef Stats<false, Move> CountermovesStats;
6665

6766

6867
/// MovePicker class is used to pick one pseudo legal move at a time from the
@@ -77,17 +76,19 @@ class MovePicker {
7776
MovePicker& operator=(const MovePicker&); // Silence a warning under MSVC
7877

7978
public:
80-
MovePicker(const Position&, Move, Depth, const History&, const Refutations&, Search::Stack*, Value);
81-
MovePicker(const Position&, Move, Depth, const History&, Square);
82-
MovePicker(const Position&, Move, const History&, PieceType);
79+
MovePicker(const Position&, Move, Depth, const HistoryStats&, Square);
80+
MovePicker(const Position&, Move, const HistoryStats&, PieceType);
81+
MovePicker(const Position&, Move, Depth, const HistoryStats&,
82+
const CountermovesStats&, Search::Stack*, Value);
83+
8384
template<bool SpNode> Move next_move();
8485

8586
private:
8687
template<GenType> void score();
8788
void generate_next();
8889

8990
const Position& pos;
90-
const History& Hist;
91+
const HistoryStats& history;
9192
Search::Stack* ss;
9293
Depth depth;
9394
Move ttMove;

src/search.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ namespace {
8686
TimeManager TimeMgr;
8787
int BestMoveChanges;
8888
Value DrawValue[COLOR_NB];
89-
History Hist;
90-
Gains Gain;
91-
Refutations Refutation;
89+
HistoryStats History;
90+
GainsStats Gains;
91+
CountermovesStats Countermoves;
9292

9393
template <NodeType NT>
9494
Value search(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth);
@@ -304,9 +304,9 @@ namespace {
304304
bestValue = delta = -VALUE_INFINITE;
305305
ss->currentMove = MOVE_NULL; // Hack to skip update gains
306306
TT.new_search();
307-
Hist.clear();
308-
Gain.clear();
309-
Refutation.clear();
307+
History.clear();
308+
Gains.clear();
309+
Countermoves.clear();
310310

311311
PVSize = Options["MultiPV"];
312312
Skill skill(Options["Skill Level"]);
@@ -623,7 +623,7 @@ namespace {
623623
&& type_of(move) == NORMAL)
624624
{
625625
Square to = to_sq(move);
626-
Gain.update(pos.piece_on(to), to, -(ss-1)->staticEval - ss->staticEval);
626+
Gains.update(pos.piece_on(to), to, -(ss-1)->staticEval - ss->staticEval);
627627
}
628628

629629
// Step 6. Razoring (is omitted in PV nodes)
@@ -734,7 +734,7 @@ namespace {
734734
assert((ss-1)->currentMove != MOVE_NONE);
735735
assert((ss-1)->currentMove != MOVE_NULL);
736736

737-
MovePicker mp(pos, ttMove, Hist, pos.captured_piece_type());
737+
MovePicker mp(pos, ttMove, History, pos.captured_piece_type());
738738
CheckInfo ci(pos);
739739

740740
while ((move = mp.next_move<false>()) != MOVE_NONE)
@@ -766,7 +766,7 @@ namespace {
766766

767767
split_point_start: // At split points actual search starts from here
768768

769-
MovePicker mp(pos, ttMove, depth, Hist, Refutation, ss, PvNode ? -VALUE_INFINITE : beta);
769+
MovePicker mp(pos, ttMove, depth, History, Countermoves, ss, PvNode ? -VALUE_INFINITE : beta);
770770
CheckInfo ci(pos);
771771
value = bestValue; // Workaround a bogus 'uninitialized' warning under gcc
772772
singularExtensionNode = !RootNode
@@ -884,7 +884,7 @@ namespace {
884884
// but fixing this made program slightly weaker.
885885
Depth predictedDepth = newDepth - reduction<PvNode>(depth, moveCount);
886886
futilityValue = ss->staticEval + ss->evalMargin + futility_margin(predictedDepth, moveCount)
887-
+ Gain[pos.piece_moved(move)][to_sq(move)];
887+
+ Gains[pos.piece_moved(move)][to_sq(move)];
888888

889889
if (futilityValue < beta)
890890
{
@@ -1091,18 +1091,18 @@ namespace {
10911091

10921092
// Increase history value of the cut-off move
10931093
Value bonus = Value(int(depth) * int(depth));
1094-
Hist.update(pos.piece_moved(bestMove), to_sq(bestMove), bonus);
1094+
History.update(pos.piece_moved(bestMove), to_sq(bestMove), bonus);
10951095
if (is_ok((ss-1)->currentMove))
10961096
{
10971097
Square prevSq = to_sq((ss-1)->currentMove);
1098-
Refutation.update(pos.piece_on(prevSq), prevSq, bestMove);
1098+
Countermoves.update(pos.piece_on(prevSq), prevSq, bestMove);
10991099
}
11001100

11011101
// Decrease history of all the other played non-capture moves
11021102
for (int i = 0; i < playedMoveCount - 1; i++)
11031103
{
11041104
Move m = movesSearched[i];
1105-
Hist.update(pos.piece_moved(m), to_sq(m), -bonus);
1105+
History.update(pos.piece_moved(m), to_sq(m), -bonus);
11061106
}
11071107
}
11081108
}
@@ -1215,7 +1215,7 @@ namespace {
12151215
// to search the moves. Because the depth is <= 0 here, only captures,
12161216
// queen promotions and checks (only if depth >= DEPTH_QS_CHECKS) will
12171217
// be generated.
1218-
MovePicker mp(pos, ttMove, depth, Hist, to_sq((ss-1)->currentMove));
1218+
MovePicker mp(pos, ttMove, depth, History, to_sq((ss-1)->currentMove));
12191219
CheckInfo ci(pos);
12201220

12211221
// Loop through the moves until no moves remain or a beta cutoff occurs

0 commit comments

Comments
 (0)