X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.h;h=406dca5aa82b5da3b91014f7860a093df8c91389;hp=d822260dd768fb6eca1776435d80fb39cb7ad318;hb=c2a4856f9e9aad8122f2386acdacf7aa385cfc1b;hpb=c9b24c3358a26afdec5e33e369b6192039562971 diff --git a/src/position.h b/src/position.h index d822260d..406dca5a 100644 --- a/src/position.h +++ b/src/position.h @@ -47,7 +47,7 @@ struct CheckInfo { /// Castle rights, encoded as bit fields -enum CastleRights { +enum CastleRight { CASTLES_NONE = 0, WHITE_OO = 1, BLACK_OO = 2, @@ -154,11 +154,9 @@ public: Square king_square(Color c) const; // Castling rights - bool can_castle_kingside(Color c) const; - bool can_castle_queenside(Color c) const; + bool can_castle(CastleRight f) const; bool can_castle(Color c) const; - Square initial_kr_square(Color c) const; - Square initial_qr_square(Color c) const; + Square castle_rook_square(CastleRight f) const; // Bitboards for pinned pieces and discovered check candidates Bitboard discovered_check_candidates(Color c) const; @@ -251,8 +249,7 @@ private: void clear(); void detach(); void put_piece(Piece p, Square s); - void set_castle_kingside(Color c); - void set_castle_queenside(Color c); + void set_castle(int f, Square ksq, Square rsq); void set_castling_rights(char token); bool move_is_pl_slow(const Move m) const; @@ -292,8 +289,8 @@ private: Color sideToMove; Key history[MaxGameLength]; int castleRightsMask[64]; + Square castleRookSquare[16]; // [CastleRights] StateInfo startState; - File initialKFile, initialKRFile, initialQRFile; bool chess960; int fullMoves; int threadID; @@ -381,32 +378,16 @@ inline Square Position::king_square(Color c) const { return pieceList[c][KING][0]; } -inline bool Position::can_castle_kingside(Color c) const { - return st->castleRights & (WHITE_OO << c); -} - -inline bool Position::can_castle_queenside(Color c) const { - return st->castleRights & (WHITE_OOO << c); +inline bool Position::can_castle(CastleRight f) const { + return st->castleRights & f; } inline bool Position::can_castle(Color c) const { return st->castleRights & ((WHITE_OO | WHITE_OOO) << c); } -inline void Position::set_castle_kingside(Color c) { - st->castleRights |= (WHITE_OO << c); -} - -inline void Position::set_castle_queenside(Color c) { - st->castleRights |= (WHITE_OOO << c); -} - -inline Square Position::initial_kr_square(Color c) const { - return relative_square(c, make_square(initialKRFile, RANK_1)); -} - -inline Square Position::initial_qr_square(Color c) const { - return relative_square(c, make_square(initialQRFile, RANK_1)); +inline Square Position::castle_rook_square(CastleRight f) const { + return castleRookSquare[f]; } template<>