mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Avoid recalculating CheckInfo in generate_castling()
No functional change.
This commit is contained in:
parent
64a71c3c02
commit
9fcefb2760
1 changed files with 10 additions and 8 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue