mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 00:33:09 +00:00
Remove Some Bitboard Arrays (#1963)
This is non-functional. These 5 arrays are simple enough to calculate real-time and maintaining an array for them does not help. Decreases the memory footprint. This seems a tiny bit slower on my machine, but passed STC well enough. Could someone verify speed? STC LLR: 2.95 (-2.94,2.94) [-3.00,1.00] Total: 44745 W: 9780 L: 9704 D: 25261 http://tests.stockfishchess.org/tests/view/5c47aa2d0ebc5902bca13fc4 The slowdown is minimal even in 32 bit case (thanks to @mstembera for testing): Compiled using make build ARCH=x86-32 CXX=i686-w64-mingw32-c++ and benched This patch only: ``` Results for 40 tests for each version: Base Test Diff Mean 1455204 1450033 5171 StDev 49452 34533 59621 p-value: 0.465 speedup: -0.004 ``` No functional change.
This commit is contained in:
parent
6514500236
commit
dd4796fcd5
2 changed files with 9 additions and 36 deletions
|
@ -27,15 +27,10 @@ uint8_t PopCnt16[1 << 16];
|
|||
int8_t SquareDistance[SQUARE_NB][SQUARE_NB];
|
||||
|
||||
Bitboard SquareBB[SQUARE_NB];
|
||||
Bitboard FileBB[FILE_NB];
|
||||
Bitboard RankBB[RANK_NB];
|
||||
Bitboard ForwardRanksBB[COLOR_NB][RANK_NB];
|
||||
Bitboard BetweenBB[SQUARE_NB][SQUARE_NB];
|
||||
Bitboard LineBB[SQUARE_NB][SQUARE_NB];
|
||||
Bitboard DistanceRingBB[SQUARE_NB][8];
|
||||
Bitboard ForwardFileBB[COLOR_NB][SQUARE_NB];
|
||||
Bitboard PassedPawnMask[COLOR_NB][SQUARE_NB];
|
||||
Bitboard PawnAttackSpan[COLOR_NB][SQUARE_NB];
|
||||
Bitboard PseudoAttacks[PIECE_TYPE_NB][SQUARE_NB];
|
||||
Bitboard PawnAttacks[COLOR_NB][SQUARE_NB];
|
||||
|
||||
|
@ -90,22 +85,8 @@ void Bitboards::init() {
|
|||
for (Square s = SQ_A1; s <= SQ_H8; ++s)
|
||||
SquareBB[s] = (1ULL << s);
|
||||
|
||||
for (File f = FILE_A; f <= FILE_H; ++f)
|
||||
FileBB[f] = f > FILE_A ? FileBB[f - 1] << 1 : FileABB;
|
||||
|
||||
for (Rank r = RANK_1; r <= RANK_8; ++r)
|
||||
RankBB[r] = r > RANK_1 ? RankBB[r - 1] << 8 : Rank1BB;
|
||||
|
||||
for (Rank r = RANK_1; r < RANK_8; ++r)
|
||||
ForwardRanksBB[WHITE][r] = ~(ForwardRanksBB[BLACK][r + 1] = ForwardRanksBB[BLACK][r] | RankBB[r]);
|
||||
|
||||
for (Color c = WHITE; c <= BLACK; ++c)
|
||||
for (Square s = SQ_A1; s <= SQ_H8; ++s)
|
||||
{
|
||||
ForwardFileBB [c][s] = ForwardRanksBB[c][rank_of(s)] & FileBB[file_of(s)];
|
||||
PawnAttackSpan[c][s] = ForwardRanksBB[c][rank_of(s)] & adjacent_files_bb(file_of(s));
|
||||
PassedPawnMask[c][s] = ForwardFileBB [c][s] | PawnAttackSpan[c][s];
|
||||
}
|
||||
ForwardRanksBB[WHITE][r] = ~(ForwardRanksBB[BLACK][r + 1] = ForwardRanksBB[BLACK][r] | rank_bb(r));
|
||||
|
||||
for (Square s1 = SQ_A1; s1 <= SQ_H8; ++s1)
|
||||
for (Square s2 = SQ_A1; s2 <= SQ_H8; ++s2)
|
||||
|
|
|
@ -63,15 +63,10 @@ constexpr Bitboard Rank8BB = Rank1BB << (8 * 7);
|
|||
extern int8_t SquareDistance[SQUARE_NB][SQUARE_NB];
|
||||
|
||||
extern Bitboard SquareBB[SQUARE_NB];
|
||||
extern Bitboard FileBB[FILE_NB];
|
||||
extern Bitboard RankBB[RANK_NB];
|
||||
extern Bitboard ForwardRanksBB[COLOR_NB][RANK_NB];
|
||||
extern Bitboard BetweenBB[SQUARE_NB][SQUARE_NB];
|
||||
extern Bitboard LineBB[SQUARE_NB][SQUARE_NB];
|
||||
extern Bitboard DistanceRingBB[SQUARE_NB][8];
|
||||
extern Bitboard ForwardFileBB[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];
|
||||
|
||||
|
@ -142,19 +137,19 @@ inline bool opposite_colors(Square s1, Square s2) {
|
|||
/// the given file or rank.
|
||||
|
||||
inline Bitboard rank_bb(Rank r) {
|
||||
return RankBB[r];
|
||||
return Rank1BB << (8 * r);
|
||||
}
|
||||
|
||||
inline Bitboard rank_bb(Square s) {
|
||||
return RankBB[rank_of(s)];
|
||||
return rank_bb(rank_of(s));
|
||||
}
|
||||
|
||||
inline Bitboard file_bb(File f) {
|
||||
return FileBB[f];
|
||||
return FileABB << f;
|
||||
}
|
||||
|
||||
inline Bitboard file_bb(Square s) {
|
||||
return FileBB[file_of(s)];
|
||||
return file_bb(file_of(s));
|
||||
}
|
||||
|
||||
|
||||
|
@ -194,10 +189,9 @@ constexpr Bitboard double_pawn_attacks_bb(Bitboard b) {
|
|||
/// adjacent files of the given one.
|
||||
|
||||
inline Bitboard adjacent_files_bb(File f) {
|
||||
return shift<EAST>(FileBB[f]) | shift<WEST>(FileBB[f]);
|
||||
return shift<EAST>(file_bb(f)) | shift<WEST>(file_bb(f));
|
||||
}
|
||||
|
||||
|
||||
/// between_bb() returns a bitboard representing all the squares between the two
|
||||
/// given ones. For instance, between_bb(SQ_C4, SQ_F7) returns a bitboard with
|
||||
/// the bits for square d5 and e6 set. If s1 and s2 are not on the same rank, file
|
||||
|
@ -222,26 +216,24 @@ inline Bitboard forward_ranks_bb(Color c, Square s) {
|
|||
/// ForwardFileBB[c][s] = forward_ranks_bb(c, s) & file_bb(s)
|
||||
|
||||
inline Bitboard forward_file_bb(Color c, Square s) {
|
||||
return ForwardFileBB[c][s];
|
||||
return ForwardRanksBB[c][rank_of(s)] & file_bb(s);
|
||||
}
|
||||
|
||||
|
||||
/// pawn_attack_span() returns a bitboard representing all the squares that can be
|
||||
/// attacked by a pawn of the given color when it moves along its file, starting
|
||||
/// from the given square:
|
||||
/// PawnAttackSpan[c][s] = forward_ranks_bb(c, s) & adjacent_files_bb(file_of(s));
|
||||
|
||||
inline Bitboard pawn_attack_span(Color c, Square s) {
|
||||
return PawnAttackSpan[c][s];
|
||||
return forward_ranks_bb(c, s) & adjacent_files_bb(file_of(s));
|
||||
}
|
||||
|
||||
|
||||
/// passed_pawn_mask() returns a bitboard mask which can be used to test if a
|
||||
/// pawn of the given color and on the given square is a passed pawn:
|
||||
/// PassedPawnMask[c][s] = pawn_attack_span(c, s) | forward_file_bb(c, s)
|
||||
|
||||
inline Bitboard passed_pawn_mask(Color c, Square s) {
|
||||
return PassedPawnMask[c][s];
|
||||
return pawn_attack_span(c, s) | forward_file_bb(c, s);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue