mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-21 09:37:16 +08:00
Speedup and simplify pinners and blockers
To compute dicovered check or pinned pieces we use some bitwise
operators that are not really needed because already accounted for
at the caller site.
For instance in evaluation we compute:
pos.pinned_pieces(Us) & s
Where pinned_pieces() is:
st->blockersForKing[c] & pieces(c)
So in this case the & operator with pieces(c) is useless,
given the outer '& s'.
There are many places where we can use the naked blockersForKing[]
instead of the full pinned_pieces() or discovered_check_candidates().
This path is simpler than original and gives around 1% speed up for me.
Also tested for speed by mstembera and snicolet (neutral in both cases).
No functional change.
This commit is contained in:
committed by
Stéphane Nicolet
parent
d438720a1c
commit
ad2a0e356e
@@ -135,7 +135,7 @@ namespace {
|
||||
// if the pawn is not on the same file as the enemy king, because we
|
||||
// don't generate captures. Note that a possible discovery check
|
||||
// promotion has been already generated amongst the captures.
|
||||
Bitboard dcCandidates = pos.discovered_check_candidates();
|
||||
Bitboard dcCandidates = pos.blockers_for_king(Them);
|
||||
if (pawnsNotOn7 & dcCandidates)
|
||||
{
|
||||
Bitboard dc1 = shift<Up>(pawnsNotOn7 & dcCandidates) & emptySquares & ~file_bb(ksq);
|
||||
@@ -241,7 +241,7 @@ namespace {
|
||||
&& !(PseudoAttacks[Pt][from] & target & pos.check_squares(Pt)))
|
||||
continue;
|
||||
|
||||
if (pos.discovered_check_candidates() & from)
|
||||
if (pos.blockers_for_king(~us) & from)
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -336,7 +336,7 @@ ExtMove* generate<QUIET_CHECKS>(const Position& pos, ExtMove* moveList) {
|
||||
assert(!pos.checkers());
|
||||
|
||||
Color us = pos.side_to_move();
|
||||
Bitboard dc = pos.discovered_check_candidates();
|
||||
Bitboard dc = pos.blockers_for_king(~us) & pos.pieces(us);
|
||||
|
||||
while (dc)
|
||||
{
|
||||
@@ -403,8 +403,9 @@ ExtMove* generate<EVASIONS>(const Position& pos, ExtMove* moveList) {
|
||||
template<>
|
||||
ExtMove* generate<LEGAL>(const Position& pos, ExtMove* moveList) {
|
||||
|
||||
Bitboard pinned = pos.pinned_pieces(pos.side_to_move());
|
||||
Square ksq = pos.square<KING>(pos.side_to_move());
|
||||
Color us = pos.side_to_move();
|
||||
Bitboard pinned = pos.blockers_for_king(us) & pos.pieces(us);
|
||||
Square ksq = pos.square<KING>(us);
|
||||
ExtMove* cur = moveList;
|
||||
|
||||
moveList = pos.checkers() ? generate<EVASIONS >(pos, moveList)
|
||||
|
||||
Reference in New Issue
Block a user