1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 00:33:09 +00:00

Avoid recalculating CheckInfo in generate_castling()

No functional change.
This commit is contained in:
Marco Costalba 2014-02-20 08:27:13 +01:00
parent 64a71c3c02
commit 9fcefb2760

View file

@ -32,7 +32,7 @@
namespace {
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)))
return mlist;
@ -59,10 +59,12 @@ namespace {
if (Chess960 && (attacks_bb<ROOK>(kto, pos.pieces() ^ rfrom) & pos.pieces(~us, ROOK, QUEEN)))
return mlist;
(mlist++)->move = make<CASTLING>(kfrom, rfrom);
Move m = make<CASTLING>(kfrom, rfrom);
if (Checks && !pos.gives_check((mlist - 1)->move, CheckInfo(pos)))
--mlist;
if (Checks && !pos.gives_check(m, *ci))
return mlist;
(mlist++)->move = m;
return mlist;
}
@ -260,13 +262,13 @@ namespace {
{
if (pos.is_chess960())
{
mlist = generate_castling< KING_SIDE, Checks, true>(pos, mlist, Us);
mlist = generate_castling<QUEEN_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, ci);
}
else
{
mlist = generate_castling< KING_SIDE, Checks, false>(pos, mlist, Us);
mlist = generate_castling<QUEEN_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, ci);
}
}