mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-21 01:27:16 +08:00
simplify castling part of generate_all.
somewhat more compact, generates same code. close https://github.com/official-stockfish/Stockfish/pull/2580 No functional change.
This commit is contained in:
committed by
Joost VandeVondele
parent
c077bfb413
commit
442e1e0f93
@@ -214,9 +214,6 @@ namespace {
|
||||
|
||||
template<Color Us, GenType Type>
|
||||
ExtMove* generate_all(const Position& pos, ExtMove* moveList, Bitboard target) {
|
||||
|
||||
constexpr CastlingRights OO = Us & KING_SIDE;
|
||||
constexpr CastlingRights OOO = Us & QUEEN_SIDE;
|
||||
constexpr bool Checks = Type == QUIET_CHECKS; // Reduce template instantations
|
||||
|
||||
moveList = generate_pawn_moves<Us, Type>(pos, moveList, target);
|
||||
@@ -232,14 +229,10 @@ namespace {
|
||||
while (b)
|
||||
*moveList++ = make_move(ksq, pop_lsb(&b));
|
||||
|
||||
if (Type != CAPTURES && pos.can_castle(CastlingRights(OO | OOO)))
|
||||
{
|
||||
if (!pos.castling_impeded(OO) && pos.can_castle(OO))
|
||||
*moveList++ = make<CASTLING>(ksq, pos.castling_rook_square(OO));
|
||||
|
||||
if (!pos.castling_impeded(OOO) && pos.can_castle(OOO))
|
||||
*moveList++ = make<CASTLING>(ksq, pos.castling_rook_square(OOO));
|
||||
}
|
||||
if ((Type != CAPTURES) && pos.can_castle(Us & ANY_CASTLING))
|
||||
for(CastlingRights cr : { Us & KING_SIDE, Us & QUEEN_SIDE } )
|
||||
if (!pos.castling_impeded(cr) && pos.can_castle(cr))
|
||||
*moveList++ = make<CASTLING>(ksq, pos.castling_rook_square(cr));
|
||||
}
|
||||
|
||||
return moveList;
|
||||
|
||||
Reference in New Issue
Block a user