mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-22 10:06:26 +08:00
Avoid recalculating CheckInfo in generate_castling()
No functional change.
This commit is contained in:
@@ -32,7 +32,7 @@
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
template<CastlingSide Side, bool Checks, bool Chess960>
|
template<CastlingSide Side, bool Checks, bool Chess960>
|
||||||
ExtMove* generate_castling(const Position& pos, ExtMove* mlist, Color us) {
|
ExtMove* generate_castling(const Position& pos, ExtMove* mlist, Color us, const CheckInfo* ci) {
|
||||||
|
|
||||||
if (pos.castling_impeded(us, Side) || !pos.can_castle(make_castling_flag(us, Side)))
|
if (pos.castling_impeded(us, Side) || !pos.can_castle(make_castling_flag(us, Side)))
|
||||||
return mlist;
|
return mlist;
|
||||||
@@ -59,10 +59,12 @@ namespace {
|
|||||||
if (Chess960 && (attacks_bb<ROOK>(kto, pos.pieces() ^ rfrom) & pos.pieces(~us, ROOK, QUEEN)))
|
if (Chess960 && (attacks_bb<ROOK>(kto, pos.pieces() ^ rfrom) & pos.pieces(~us, ROOK, QUEEN)))
|
||||||
return mlist;
|
return mlist;
|
||||||
|
|
||||||
(mlist++)->move = make<CASTLING>(kfrom, rfrom);
|
Move m = make<CASTLING>(kfrom, rfrom);
|
||||||
|
|
||||||
if (Checks && !pos.gives_check((mlist - 1)->move, CheckInfo(pos)))
|
if (Checks && !pos.gives_check(m, *ci))
|
||||||
--mlist;
|
return mlist;
|
||||||
|
|
||||||
|
(mlist++)->move = m;
|
||||||
|
|
||||||
return mlist;
|
return mlist;
|
||||||
}
|
}
|
||||||
@@ -260,13 +262,13 @@ namespace {
|
|||||||
{
|
{
|
||||||
if (pos.is_chess960())
|
if (pos.is_chess960())
|
||||||
{
|
{
|
||||||
mlist = generate_castling< KING_SIDE, Checks, true>(pos, mlist, Us);
|
mlist = generate_castling< KING_SIDE, Checks, true>(pos, mlist, Us, ci);
|
||||||
mlist = generate_castling<QUEEN_SIDE, Checks, true>(pos, mlist, Us);
|
mlist = generate_castling<QUEEN_SIDE, Checks, true>(pos, mlist, Us, ci);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mlist = generate_castling< KING_SIDE, Checks, false>(pos, mlist, Us);
|
mlist = generate_castling< KING_SIDE, Checks, false>(pos, mlist, Us, ci);
|
||||||
mlist = generate_castling<QUEEN_SIDE, Checks, false>(pos, mlist, Us);
|
mlist = generate_castling<QUEEN_SIDE, Checks, false>(pos, mlist, Us, ci);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user