X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=bc6efb7f646d05bb242b94b3f3d5eea48b426eb6;hp=efac40b328a647414f64bb661da106fe023c59ea;hb=9da1f45b1d310fbe213a7f51916e098fba837a9a;hpb=201e8d5f87a2bbd2d199b744cf8e92213c1e4bc4 diff --git a/src/position.cpp b/src/position.cpp index efac40b3..bc6efb7f 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; } @@ -149,9 +152,9 @@ Position::Position(const Position& pos, int th) { nodes = 0; } -Position::Position(const string& fen, int th) { +Position::Position(const string& fen, bool isChess960, int th) { - from_fen(fen); + from_fen(fen, isChess960); threadID = th; } @@ -172,7 +175,7 @@ void Position::detach() { /// string. This function is not very robust - make sure that input FENs are /// correct (this is assumed to be the responsibility of the GUI). -void Position::from_fen(const string& fen) { +void Position::from_fen(const string& fen, bool c960) { /* A FEN string defines a particular position using only the ASCII character set. @@ -271,10 +274,7 @@ void Position::from_fen(const string& fen) { castleRightsMask[make_square(initialQRFile, RANK_1)] ^= WHITE_OOO; castleRightsMask[make_square(initialQRFile, RANK_8)] ^= BLACK_OOO; - isChess960 = initialKFile != FILE_E - || initialQRFile != FILE_A - || initialKRFile != FILE_H; - + isChess960 = c960; find_checkers(); st->key = compute_key(); @@ -635,9 +635,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 +695,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; }