template<CastlingSide Side, bool OnlyChecks>
MoveStack* generate_castle(const Position& pos, MoveStack* mlist, Color us) {
template<CastlingSide Side, bool OnlyChecks>
MoveStack* generate_castle(const Position& pos, MoveStack* mlist, Color us) {
- const CastleRight CR[] = { Side ? WHITE_OOO : WHITE_OO,
- Side ? BLACK_OOO : BLACK_OO };
-
- if (pos.castle_impeded(CR[us]) || !pos.can_castle(CR[us]))
+ if (pos.castle_impeded(us, Side) || !pos.can_castle(make_castle_right(us, Side)))
return mlist;
// After castling, the rook and king final positions are the same in Chess960
// as they would be in standard chess.
Square kfrom = pos.king_square(us);
return mlist;
// After castling, the rook and king final positions are the same in Chess960
// as they would be in standard chess.
Square kfrom = pos.king_square(us);
Square kto = relative_square(us, Side == KING_SIDE ? SQ_G1 : SQ_C1);
Bitboard enemies = pos.pieces(~us);
assert(!pos.in_check());
Square kto = relative_square(us, Side == KING_SIDE ? SQ_G1 : SQ_C1);
Bitboard enemies = pos.pieces(~us);
assert(!pos.in_check());
for (Square s = std::min(kfrom, kto), e = std::max(kfrom, kto); s <= e; s++)
if ( s != kfrom // We are not in check
for (Square s = std::min(kfrom, kto), e = std::max(kfrom, kto); s <= e; s++)
if ( s != kfrom // We are not in check