Fix the handling of opposite bishops in KXK endgame evaluation
authortthsqe12 <tthsqe12@gmail.com>
Sat, 12 Aug 2017 08:50:38 +0000 (10:50 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 12 Aug 2017 09:47:11 +0000 (02:47 -0700)
The case of three or more bishops against a long king must look at all of the
bishops and not just the first two in the piece lists. This patch makes sure
that the position is treated as a win when there are bishops on opposite
colors. This functional change is very small because bench remains the same.

LLR: 2.95 (-2.94,2.94) [-4.00,0.00]
Total: 24249 W: 4349 L: 4275 D: 15625
http://tests.stockfishchess.org/tests/view/598186530ebc5916ff64a218

Bench: 5608839

src/endgame.cpp

index a5390b1ab46227f59a0e1e3c5b10b148e542f0cb..ca17f6ac8fcccb2672dcc932e4dbb46f60b048f5 100644 (file)
@@ -135,8 +135,8 @@ Value Endgame<KXK>::operator()(const Position& pos) const {
   if (   pos.count<QUEEN>(strongSide)
       || pos.count<ROOK>(strongSide)
       ||(pos.count<BISHOP>(strongSide) && pos.count<KNIGHT>(strongSide))
-      ||(pos.count<BISHOP>(strongSide) > 1 && opposite_colors(pos.squares<BISHOP>(strongSide)[0],
-                                                              pos.squares<BISHOP>(strongSide)[1])))
+      || (   (pos.pieces(strongSide, BISHOP) & ~DarkSquares)
+          && (pos.pieces(strongSide, BISHOP) &  DarkSquares)))
       result = std::min(result + VALUE_KNOWN_WIN, VALUE_MATE_IN_MAX_PLY - 1);
 
   return strongSide == pos.side_to_move() ? result : -result;