]> git.sesse.net Git - stockfish/commitdiff
Fix brekage from previous patches
authorMarco Costalba <mcostalba@gmail.com>
Wed, 18 May 2011 05:46:08 +0000 (06:46 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 18 May 2011 06:05:36 +0000 (07:05 +0100)
It is interesting the fact that we need to test for
move_is_castle(m) anyway and not relying on testing
if destination square is attacked. Indeed the latter
condition fails if the castling rook is attacked,
castling is coded as "king captures the rook" but it
is legal in that case.

Verified no functional change with beginning of the series.

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

index 59caa88e47e4b0bcc8220b4c9d8617b23f799946..59c3a8c39f882f1bcb347f6dfeda5a78acfc7c10 100644 (file)
@@ -603,9 +603,10 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const {
   assert(piece_on(king_square(us)) == make_piece(us, KING));
 
   // If the moving piece is a king, check whether the destination
   assert(piece_on(king_square(us)) == make_piece(us, KING));
 
   // If the moving piece is a king, check whether the destination
-  // square is attacked by the opponent.
+  // square is attacked by the opponent. Castling moves are checked
+  // for legality during move generation.
   if (type_of_piece_on(from) == KING)
   if (type_of_piece_on(from) == KING)
-      return !(attackers_to(move_to(m)) & pieces_of_color(opposite_color(us)));
+      return move_is_castle(m) || !(attackers_to(move_to(m)) & pieces_of_color(opposite_color(us)));
 
   // A non-king move is legal if and only if it is not pinned or it
   // is moving along the ray towards or away from the king.
 
   // A non-king move is legal if and only if it is not pinned or it
   // is moving along the ray towards or away from the king.
index 04592d27348b8ac9e9c62463f6505a5270e955b8..5935181b5bf704fe7a41e83ee877756a892a7ff0 100644 (file)
@@ -526,7 +526,7 @@ inline bool Position::is_chess960() const {
 inline bool Position::move_is_capture(Move m) const {
 
   assert (m != MOVE_NONE && m != MOVE_NULL);
 inline bool Position::move_is_capture(Move m) const {
 
   assert (m != MOVE_NONE && m != MOVE_NULL);
-  return !square_is_empty(move_to(m)) || move_is_ep(m);
+  return !move_is_special(m) ? !square_is_empty(move_to(m)) : move_is_ep(m);
 }
 
 inline PieceType Position::captured_piece_type() const {
 }
 
 inline PieceType Position::captured_piece_type() const {