X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fposition.cpp;h=f0301e4ec9308af1a78394c5728b0246b1af30a3;hb=0007b43a91dde70f73edd846f0371200647acd25;hp=efac40b328a647414f64bb661da106fe023c59ea;hpb=201e8d5f87a2bbd2d199b744cf8e92213c1e4bc4;p=stockfish diff --git a/src/position.cpp b/src/position.cpp index efac40b3..f0301e4e 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -101,20 +101,23 @@ namespace { operator[]('B') = WB; operator[]('b') = BB; operator[]('N') = WN; operator[]('n') = BN; operator[]('P') = WP; operator[]('p') = BP; - operator[](' ') = PIECE_NONE; operator[]('.') = PIECE_NONE_DARK_SQ; + operator[](' ') = PIECE_NONE; + operator[]('.') = PIECE_NONE_DARK_SQ; } char from_piece(Piece p) const { - std::map::const_iterator it; - for (it = begin(); it != end(); ++it) - if (it->second == p) - return it->first; + std::map::const_iterator it; + for (it = begin(); it != end(); ++it) + if (it->second == p) + return it->first; - assert(false); - return 0; + assert(false); + return 0; } - } pieceLetters; + }; + + PieceLetters pieceLetters; } @@ -635,9 +638,9 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const { // 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. - return ( !pinned - || !bit_is_set(pinned, from) - || (direction_between_squares(from, king_square(us)) == direction_between_squares(move_to(m), king_square(us)))); + return !pinned + || !bit_is_set(pinned, from) + || squares_aligned(from, move_to(m), king_square(us)); } @@ -695,7 +698,7 @@ bool Position::move_is_check(Move m, const CheckInfo& ci) const { { // For pawn and king moves we need to verify also direction if ( (pt != PAWN && pt != KING) - ||(direction_between_squares(from, ci.ksq) != direction_between_squares(to, ci.ksq))) + || !squares_aligned(from, to, ci.ksq)) return true; }