Skip to content

Commit 27f2ce8

Browse files
committed
Revert "Move draw by material check"
Possible regression bench: 4554579
1 parent 45b0aea commit 27f2ce8

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

src/endgame.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ enum EndgameType {
4343
KQKP, // KQ vs KP
4444
KQKR, // KQ vs KR
4545
KBBKN, // KBB vs KN
46-
KmmKm, // K and one or two minors vs K and zero or one minor
46+
KmmKm, // K and two minors vs K and one or two minors
4747

4848

4949
// Scaling functions

src/material.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,10 @@ Entry* probe(const Position& pos, Table& entries, Endgames& endgames) {
173173
return e;
174174
}
175175

176-
// Draw by insufficient material (trivial draws like KK, KBK and KNK)
177-
if ( !pos.pieces(PAWN)
178-
&& pos.non_pawn_material(WHITE) + pos.non_pawn_material(BLACK) <= BishopValueMg)
179-
{
180-
e->evaluationFunction = &EvaluateKmmKm[pos.side_to_move()];
181-
return e;
182-
}
183-
184-
// Minor piece endgame with at least one minor piece per side and
185-
// no pawns. Note that the case KmmK is already handled by KXK.
186176
if (!pos.pieces(PAWN) && !pos.pieces(ROOK) && !pos.pieces(QUEEN))
187177
{
178+
// Minor piece endgame with at least one minor piece per side and
179+
// no pawns. Note that the case KmmK is already handled by KXK.
188180
assert((pos.pieces(WHITE, KNIGHT) | pos.pieces(WHITE, BISHOP)));
189181
assert((pos.pieces(BLACK, KNIGHT) | pos.pieces(BLACK, BISHOP)));
190182

@@ -248,7 +240,8 @@ Entry* probe(const Position& pos, Table& entries, Endgames& endgames) {
248240
}
249241
}
250242

251-
// No pawns makes it difficult to win, even with a material advantage
243+
// No pawns makes it difficult to win, even with a material advantage. This
244+
// catches some trivial draws like KK, KBK and KNK
252245
if (!pos.count<PAWN>(WHITE) && npm_w - npm_b <= BishopValueMg)
253246
{
254247
e->factor[WHITE] = (uint8_t)

src/position.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,11 +1255,17 @@ Value Position::compute_non_pawn_material(Color c) const {
12551255
}
12561256

12571257

1258-
/// Position::is_draw() tests whether the position is drawn by 50 moves rule
1259-
/// or by repetition. It does not detect stalemates.
1260-
1258+
/// Position::is_draw() tests whether the position is drawn by material,
1259+
/// repetition, or the 50 moves rule. It does not detect stalemates, this
1260+
/// must be done by the search.
12611261
bool Position::is_draw() const {
12621262

1263+
// Draw by material?
1264+
if ( !pieces(PAWN)
1265+
&& (non_pawn_material(WHITE) + non_pawn_material(BLACK) <= BishopValueMg))
1266+
return true;
1267+
1268+
// Draw by the 50 moves rule?
12631269
if (st->rule50 > 99 && (!checkers() || MoveList<LEGAL>(*this).size()))
12641270
return true;
12651271

0 commit comments

Comments
 (0)