Fix KBNK endgame
authorMarco Costalba <mcostalba@gmail.com>
Sun, 25 Jul 2010 20:47:54 +0000 (21:47 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 25 Jul 2010 20:58:09 +0000 (21:58 +0100)
Broken by recent patch. Also better document what's
happening there.

Verified to restore original behaviour.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/endgame.cpp
src/position.cpp

index 1be384410b4d4a59091528826880a3f80f668b83..24c8c5d41c344dd3cd501d6e955024eb7988ff17 100644 (file)
@@ -152,7 +152,10 @@ Value EvaluationFunction<KBNK>::apply(const Position& pos) const {
   Square loserKSq = pos.king_square(weakerSide);
   Square bishopSquare = pos.piece_list(strongerSide, BISHOP, 0);
 
-  if (same_color_squares(bishopSquare, SQ_A1))
+  // kbnk_mate_table() tries to drive toward corners A1 or H8,
+  // if we have a bishop that cannot reach the above squares we
+  // mirror the kings so to drive enemy toward corners A8 or H1.
+  if (!same_color_squares(bishopSquare, SQ_A1))
   {
       winnerKSq = flop_square(winnerKSq);
       loserKSq = flop_square(loserKSq);
index 879e96904a89314fc97e95b199f5795c56ff974d..183530fc61d731e7c03cfa6b8ee569953a1676f1 100644 (file)
@@ -400,7 +400,7 @@ void Position::print(Move move) const {
           char c = (color_of_piece_on(sq) == BLACK ? '=' : ' ');
           Piece piece = piece_on(sq);
 
-          if (piece == NO_PIECE && same_color_squares(sq, SQ_A1))
+          if (piece == NO_PIECE && square_color(sq) == DARK)
               piece = NO_PIECE_DARK_SQ;
 
           cout << c << pieceLetters.from_piece(piece) << c << '|';