mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 01:03:09 +00:00
Small tweak to generate_castle_moves()
Move the castling condition test out of the function. This avoids a function call most of the times. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
57b3ca916f
commit
44fbbeafc9
1 changed files with 35 additions and 36 deletions
|
@ -46,7 +46,7 @@ namespace {
|
|||
};
|
||||
|
||||
template<CastlingSide Side>
|
||||
MoveStack* generate_castle_moves(const Position&, MoveStack*);
|
||||
MoveStack* generate_castle_moves(const Position&, MoveStack*, Color us);
|
||||
|
||||
template<Color Us, MoveType Type>
|
||||
MoveStack* generate_pawn_moves(const Position&, MoveStack*, Bitboard, Square);
|
||||
|
@ -193,8 +193,11 @@ MoveStack* generate(const Position& pos, MoveStack* mlist) {
|
|||
|
||||
if (T != MV_CAPTURE)
|
||||
{
|
||||
mlist = generate_castle_moves<KING_SIDE>(pos, mlist);
|
||||
mlist = generate_castle_moves<QUEEN_SIDE>(pos, mlist);
|
||||
if (pos.can_castle_kingside(us))
|
||||
mlist = generate_castle_moves<KING_SIDE>(pos, mlist, us);
|
||||
|
||||
if (pos.can_castle_queenside(us))
|
||||
mlist = generate_castle_moves<QUEEN_SIDE>(pos, mlist, us);
|
||||
}
|
||||
|
||||
return mlist;
|
||||
|
@ -622,13 +625,8 @@ namespace {
|
|||
}
|
||||
|
||||
template<CastlingSide Side>
|
||||
MoveStack* generate_castle_moves(const Position& pos, MoveStack* mlist) {
|
||||
MoveStack* generate_castle_moves(const Position& pos, MoveStack* mlist, Color us) {
|
||||
|
||||
Color us = pos.side_to_move();
|
||||
|
||||
if ( (Side == KING_SIDE && pos.can_castle_kingside(us))
|
||||
||(Side == QUEEN_SIDE && pos.can_castle_queenside(us)))
|
||||
{
|
||||
Color them = opposite_color(us);
|
||||
Square ksq = pos.king_square(us);
|
||||
|
||||
|
@ -660,7 +658,8 @@ namespace {
|
|||
|
||||
if (!illegal)
|
||||
(*mlist++).move = make_castle_move(ksq, rsq);
|
||||
}
|
||||
|
||||
return mlist;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
Loading…
Add table
Reference in a new issue