mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-21 17:46:26 +08:00
Retire the misdesigned StepAttacks[] array.
StepAttacks[] is misdesigned, the color dependance is specific to pawns, and trying to generalise to king and knights, proves neither useful nor convinient in practice. So this patch reformats the code with the following changes: - Use PieceType instead of Piece in attacks_() functions - Use PseudoAttacks for KING and KNIGHT - Rename StepAttacks[] into PawnAttacks[] Original patch and idea from Alain Savard. No functional change. Closes #1086
This commit is contained in:
committed by
Joona Kiiski
parent
b1b19343cd
commit
e06a117d5e
@@ -66,7 +66,6 @@ extern Bitboard FileBB[FILE_NB];
|
||||
extern Bitboard RankBB[RANK_NB];
|
||||
extern Bitboard AdjacentFilesBB[FILE_NB];
|
||||
extern Bitboard InFrontBB[COLOR_NB][RANK_NB];
|
||||
extern Bitboard StepAttacksBB[PIECE_NB][SQUARE_NB];
|
||||
extern Bitboard BetweenBB[SQUARE_NB][SQUARE_NB];
|
||||
extern Bitboard LineBB[SQUARE_NB][SQUARE_NB];
|
||||
extern Bitboard DistanceRingBB[SQUARE_NB][8];
|
||||
@@ -74,6 +73,7 @@ extern Bitboard ForwardBB[COLOR_NB][SQUARE_NB];
|
||||
extern Bitboard PassedPawnMask[COLOR_NB][SQUARE_NB];
|
||||
extern Bitboard PawnAttackSpan[COLOR_NB][SQUARE_NB];
|
||||
extern Bitboard PseudoAttacks[PIECE_TYPE_NB][SQUARE_NB];
|
||||
extern Bitboard PawnAttacks[COLOR_NB][SQUARE_NB];
|
||||
|
||||
|
||||
/// Overloads of bitwise operators between a Bitboard and a Square for testing
|
||||
@@ -246,14 +246,16 @@ inline Bitboard attacks_bb(Square s, Bitboard occupied) {
|
||||
return (Pt == ROOK ? RookAttacks : BishopAttacks)[s][magic_index<Pt>(s, occupied)];
|
||||
}
|
||||
|
||||
inline Bitboard attacks_bb(Piece pc, Square s, Bitboard occupied) {
|
||||
inline Bitboard attacks_bb(PieceType pt, Square s, Bitboard occupied) {
|
||||
|
||||
switch (type_of(pc))
|
||||
assert(pt != PAWN);
|
||||
|
||||
switch (pt)
|
||||
{
|
||||
case BISHOP: return attacks_bb<BISHOP>(s, occupied);
|
||||
case ROOK : return attacks_bb<ROOK>(s, occupied);
|
||||
case QUEEN : return attacks_bb<BISHOP>(s, occupied) | attacks_bb<ROOK>(s, occupied);
|
||||
default : return StepAttacksBB[pc][s];
|
||||
default : return PseudoAttacks[pt][s];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user