mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-23 10:36:26 +08:00
Consolidate all attacks bitboards
This is a non-functional simplification that simplifies getting attacks bitboards.
* consolidates all attacks to attacks_bb (remove Position::attacks_from(..)).
* attacks_bb<PieceType>(square) gets pseudo attacks
* attacks_bb<PieceType>(square, bitboard) gets attacks considering occupied squares in the bitboard).
* pawn_attacks_bb(Color, Square) gets pawn attacks like other pawn attack bitboards.
* Wraps all access to PawnAttacks arrays and PseudoAttacks arrays and adds asserts as appropriate.
Passed STC
LLR: 2.95 (-2.94,2.94) {-1.50,0.50}
Total: 90208 W: 17533 L: 17482 D: 55193
Ptnml(0-2): 1412, 10232, 21798, 10217, 1445
https://tests.stockfishchess.org/tests/view/5ece996275787cc0c05d9790
closes https://github.com/official-stockfish/Stockfish/pull/2703
No functional change
This commit is contained in:
committed by
Joost VandeVondele
parent
fb8095718b
commit
a5e3b4edde
@@ -112,7 +112,7 @@ namespace {
|
||||
if ( distance(ksq[WHITE], ksq[BLACK]) <= 1
|
||||
|| ksq[WHITE] == psq
|
||||
|| ksq[BLACK] == psq
|
||||
|| (stm == WHITE && (PawnAttacks[WHITE][psq] & ksq[BLACK])))
|
||||
|| (stm == WHITE && (pawn_attacks_bb(WHITE, psq) & ksq[BLACK])))
|
||||
result = INVALID;
|
||||
|
||||
// Immediate win if a pawn can be promoted without getting captured
|
||||
@@ -120,13 +120,13 @@ namespace {
|
||||
&& rank_of(psq) == RANK_7
|
||||
&& ksq[stm] != psq + NORTH
|
||||
&& ( distance(ksq[~stm], psq + NORTH) > 1
|
||||
|| (PseudoAttacks[KING][ksq[stm]] & (psq + NORTH))))
|
||||
|| (attacks_bb<KING>(ksq[stm]) & (psq + NORTH))))
|
||||
result = WIN;
|
||||
|
||||
// Immediate draw if it is a stalemate or a king captures undefended pawn
|
||||
else if ( stm == BLACK
|
||||
&& ( !(PseudoAttacks[KING][ksq[stm]] & ~(PseudoAttacks[KING][ksq[~stm]] | PawnAttacks[~stm][psq]))
|
||||
|| (PseudoAttacks[KING][ksq[stm]] & psq & ~PseudoAttacks[KING][ksq[~stm]])))
|
||||
&& ( !(attacks_bb<KING>(ksq[stm]) & ~(attacks_bb<KING>(ksq[~stm]) | pawn_attacks_bb(~stm, psq)))
|
||||
|| (attacks_bb<KING>(ksq[stm]) & psq & ~attacks_bb<KING>(ksq[~stm]))))
|
||||
result = DRAW;
|
||||
|
||||
// Position will be classified later
|
||||
@@ -149,7 +149,7 @@ namespace {
|
||||
const Result Bad = (stm == WHITE ? DRAW : WIN);
|
||||
|
||||
Result r = INVALID;
|
||||
Bitboard b = PseudoAttacks[KING][ksq[stm]];
|
||||
Bitboard b = attacks_bb<KING>(ksq[stm]);
|
||||
|
||||
while (b)
|
||||
r |= stm == WHITE ? db[index(BLACK, ksq[BLACK] , pop_lsb(&b), psq)]
|
||||
|
||||
Reference in New Issue
Block a user