mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 00:56:39 +08:00
Compute checkers from scratch
This micro-optimization only complicates the code and provides no benefit. Removing it is even a speedup on my machine (i7-3770k, linux, gcc 4.9.1): stat test master diff mean 2,403,118 2,390,904 12,214 stdev 12,043 10,620 3,677 speedup 0.51% P(speedup>0) 100.0% No functional change.
This commit is contained in:
@@ -687,10 +687,10 @@ bool Position::gives_check(Move m, const CheckInfo& ci) const {
|
||||
void Position::do_move(Move m, StateInfo& newSt) {
|
||||
|
||||
CheckInfo ci(*this);
|
||||
do_move(m, newSt, ci, gives_check(m, ci));
|
||||
do_move(m, newSt, gives_check(m, ci));
|
||||
}
|
||||
|
||||
void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool givesCheck) {
|
||||
void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) {
|
||||
|
||||
assert(is_ok(m));
|
||||
assert(&newSt != st);
|
||||
@@ -848,32 +848,8 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool gives
|
||||
// Update the key with the final value
|
||||
st->key = k;
|
||||
|
||||
// Update checkers bitboard: piece must be already moved due to attacks_from()
|
||||
st->checkersBB = 0;
|
||||
|
||||
if (givesCheck)
|
||||
{
|
||||
if (type_of(m) != NORMAL)
|
||||
st->checkersBB = attackers_to(king_square(them)) & pieces(us);
|
||||
else
|
||||
{
|
||||
// Direct checks
|
||||
if (ci.checkSq[pt] & to)
|
||||
st->checkersBB |= to;
|
||||
|
||||
// Discovered checks
|
||||
if (ci.dcCandidates && (ci.dcCandidates & from))
|
||||
{
|
||||
assert(pt != QUEEN);
|
||||
|
||||
if (pt != ROOK)
|
||||
st->checkersBB |= attacks_from<ROOK>(king_square(them)) & pieces(us, QUEEN, ROOK);
|
||||
|
||||
if (pt != BISHOP)
|
||||
st->checkersBB |= attacks_from<BISHOP>(king_square(them)) & pieces(us, QUEEN, BISHOP);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Calculate checkers bitboard (if move is check)
|
||||
st->checkersBB = givesCheck ? attackers_to(king_square(them)) & pieces(us) : 0;
|
||||
|
||||
sideToMove = ~sideToMove;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user