From 3300517ecb75df265489d2a9841e4fce2414fd09 Mon Sep 17 00:00:00 2001 From: protonspring Date: Mon, 14 Jan 2019 22:53:43 -0700 Subject: [PATCH] Remove AdjacentFiles This is a non-functional simplification that removes the AdjacentFiles array. This array is simple enough to calculate that the pre-calculated array provides no benefit. Reduces the memory footprint. STC LLR: 2.96 (-2.94,2.94) [-3.00,1.00] Total: 74839 W: 16390 L: 16373 D: 42076 http://tests.stockfishchess.org/tests/view/5c3d75920ebc596a450cfb67 No functionnal change --- src/bitboard.cpp | 6 +----- src/bitboard.h | 3 +-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/bitboard.cpp b/src/bitboard.cpp index 8079b783..77f49ef6 100644 --- a/src/bitboard.cpp +++ b/src/bitboard.cpp @@ -29,7 +29,6 @@ int SquareDistance[SQUARE_NB][SQUARE_NB]; Bitboard SquareBB[SQUARE_NB]; Bitboard FileBB[FILE_NB]; Bitboard RankBB[RANK_NB]; -Bitboard AdjacentFilesBB[FILE_NB]; Bitboard ForwardRanksBB[COLOR_NB][RANK_NB]; Bitboard BetweenBB[SQUARE_NB][SQUARE_NB]; Bitboard LineBB[SQUARE_NB][SQUARE_NB]; @@ -97,9 +96,6 @@ void Bitboards::init() { for (Rank r = RANK_1; r <= RANK_8; ++r) RankBB[r] = r > RANK_1 ? RankBB[r - 1] << 8 : Rank1BB; - for (File f = FILE_A; f <= FILE_H; ++f) - AdjacentFilesBB[f] = (f > FILE_A ? FileBB[f - 1] : 0) | (f < FILE_H ? FileBB[f + 1] : 0); - for (Rank r = RANK_1; r < RANK_8; ++r) ForwardRanksBB[WHITE][r] = ~(ForwardRanksBB[BLACK][r + 1] = ForwardRanksBB[BLACK][r] | RankBB[r]); @@ -107,7 +103,7 @@ void Bitboards::init() { 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)] & AdjacentFilesBB[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]; } diff --git a/src/bitboard.h b/src/bitboard.h index f8440a23..e1c31dd7 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -65,7 +65,6 @@ extern int SquareDistance[SQUARE_NB][SQUARE_NB]; extern Bitboard SquareBB[SQUARE_NB]; extern Bitboard FileBB[FILE_NB]; extern Bitboard RankBB[RANK_NB]; -extern Bitboard AdjacentFilesBB[FILE_NB]; extern Bitboard ForwardRanksBB[COLOR_NB][RANK_NB]; extern Bitboard BetweenBB[SQUARE_NB][SQUARE_NB]; extern Bitboard LineBB[SQUARE_NB][SQUARE_NB]; @@ -195,7 +194,7 @@ constexpr Bitboard double_pawn_attacks_bb(Bitboard b) { /// adjacent files of the given one. inline Bitboard adjacent_files_bb(File f) { - return AdjacentFilesBB[f]; + return shift(FileBB[f]) | shift(FileBB[f]); } -- 2.39.2