mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-21 01:27:16 +08:00
Greatly simplify castling rights handling
No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -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<>
|
||||
|
||||
Reference in New Issue
Block a user