Skip to content

Commit fe72c93

Browse files
committed
De-templetize Position::is_draw()
Now that we always check for repetition we don't need a template anymore. No functional change.
1 parent 75221fc commit fe72c93

File tree

3 files changed

+14
-22
lines changed

3 files changed

+14
-22
lines changed

src/position.cpp

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,6 @@ Value Position::compute_non_pawn_material(Color c) const {
13761376
/// Position::is_draw() tests whether the position is drawn by material,
13771377
/// repetition, or the 50 moves rule. It does not detect stalemates, this
13781378
/// must be done by the search.
1379-
template<bool SkipRepetition>
13801379
bool Position::is_draw() const {
13811380

13821381
// Draw by material?
@@ -1389,33 +1388,26 @@ bool Position::is_draw() const {
13891388
return true;
13901389

13911390
// Draw by repetition?
1392-
if (!SkipRepetition)
1393-
{
1394-
int i = 4, e = std::min(st->rule50, st->pliesFromNull);
1391+
int i = 4, e = std::min(st->rule50, st->pliesFromNull);
13951392

1396-
if (i <= e)
1397-
{
1398-
StateInfo* stp = st->previous->previous;
1393+
if (i <= e)
1394+
{
1395+
StateInfo* stp = st->previous->previous;
13991396

1400-
do {
1401-
stp = stp->previous->previous;
1397+
do {
1398+
stp = stp->previous->previous;
14021399

1403-
if (stp->key == st->key)
1404-
return true;
1400+
if (stp->key == st->key)
1401+
return true;
14051402

1406-
i += 2;
1403+
i += 2;
14071404

1408-
} while (i <= e);
1409-
}
1405+
} while (i <= e);
14101406
}
14111407

14121408
return false;
14131409
}
14141410

1415-
// Explicit template instantiations
1416-
template bool Position::is_draw<false>() const;
1417-
template bool Position::is_draw<true>() const;
1418-
14191411

14201412
/// Position::flip() flips position with the white and black sides reversed. This
14211413
/// is only useful for debugging especially for finding evaluation symmetry bugs.

src/position.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class Position {
179179
Thread* this_thread() const;
180180
int64_t nodes_searched() const;
181181
void set_nodes_searched(int64_t n);
182-
template<bool SkipRepetition> bool is_draw() const;
182+
bool is_draw() const;
183183

184184
// Position consistency check, for debugging
185185
bool pos_is_ok(int* failedStep = NULL) const;

src/search.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ namespace {
533533
if (!RootNode)
534534
{
535535
// Step 2. Check for aborted search and immediate draw
536-
if (Signals.stop || pos.is_draw<false>() || ss->ply > MAX_PLY)
536+
if (Signals.stop || pos.is_draw() || ss->ply > MAX_PLY)
537537
return DrawValue[pos.side_to_move()];
538538

539539
// Step 3. Mate distance pruning. Even if we mate at the next move our score
@@ -1129,7 +1129,7 @@ namespace {
11291129
ss->ply = (ss-1)->ply + 1;
11301130

11311131
// Check for an instant draw or maximum ply reached
1132-
if (pos.is_draw<false>() || ss->ply > MAX_PLY)
1132+
if (pos.is_draw() || ss->ply > MAX_PLY)
11331133
return DrawValue[pos.side_to_move()];
11341134

11351135
// Decide whether or not to include checks, this fixes also the type of
@@ -1579,7 +1579,7 @@ void RootMove::extract_pv_from_tt(Position& pos) {
15791579
&& pos.is_pseudo_legal(m = tte->move()) // Local copy, TT could change
15801580
&& pos.pl_move_is_legal(m, pos.pinned_pieces())
15811581
&& ply < MAX_PLY
1582-
&& (!pos.is_draw<false>() || ply < 2));
1582+
&& (!pos.is_draw() || ply < 2));
15831583

15841584
pv.push_back(MOVE_NONE); // Must be zero-terminating
15851585

0 commit comments

Comments
 (0)