mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 00:33:09 +00:00
Retire RelativeRankBB[]
No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
45acec1865
commit
4f3fe89fb6
5 changed files with 12 additions and 45 deletions
|
@ -162,10 +162,9 @@ const int RShift[64] = {
|
|||
|
||||
#endif // defined(IS_64BIT)
|
||||
|
||||
const Bitboard LightSquaresBB = 0x55AA55AA55AA55AAULL;
|
||||
const Bitboard DarkSquaresBB = 0xAA55AA55AA55AA55ULL;
|
||||
static const Bitboard DarkSquaresBB = 0xAA55AA55AA55AA55ULL;
|
||||
|
||||
const Bitboard SquaresByColorBB[2] = { DarkSquaresBB, LightSquaresBB };
|
||||
const Bitboard SquaresByColorBB[2] = { DarkSquaresBB, ~DarkSquaresBB };
|
||||
|
||||
const Bitboard FileBB[8] = {
|
||||
FileABB, FileBBB, FileCBB, FileDBB, FileEBB, FileFBB, FileGBB, FileHBB
|
||||
|
@ -187,11 +186,6 @@ const Bitboard RankBB[8] = {
|
|||
Rank1BB, Rank2BB, Rank3BB, Rank4BB, Rank5BB, Rank6BB, Rank7BB, Rank8BB
|
||||
};
|
||||
|
||||
const Bitboard RelativeRankBB[2][8] = {
|
||||
{ Rank1BB, Rank2BB, Rank3BB, Rank4BB, Rank5BB, Rank6BB, Rank7BB, Rank8BB },
|
||||
{ Rank8BB, Rank7BB, Rank6BB, Rank5BB, Rank4BB, Rank3BB, Rank2BB, Rank1BB }
|
||||
};
|
||||
|
||||
const Bitboard InFrontBB[2][8] = {
|
||||
{ Rank2BB | Rank3BB | Rank4BB | Rank5BB | Rank6BB | Rank7BB | Rank8BB,
|
||||
Rank3BB | Rank4BB | Rank5BB | Rank6BB | Rank7BB | Rank8BB,
|
||||
|
|
|
@ -50,7 +50,6 @@ extern const Bitboard FileBB[8];
|
|||
extern const Bitboard NeighboringFilesBB[8];
|
||||
extern const Bitboard ThisAndNeighboringFilesBB[8];
|
||||
extern const Bitboard RankBB[8];
|
||||
extern const Bitboard RelativeRankBB[2][8];
|
||||
extern const Bitboard InFrontBB[2][8];
|
||||
|
||||
extern Bitboard SetMaskBB[65];
|
||||
|
@ -154,17 +153,6 @@ inline Bitboard this_and_neighboring_files_bb(Square s) {
|
|||
}
|
||||
|
||||
|
||||
/// relative_rank_bb() takes a color and a rank as input, and returns a bitboard
|
||||
/// representing all squares on the given rank from the given color's point of
|
||||
/// view. For instance, relative_rank_bb(WHITE, 7) gives all squares on the
|
||||
/// 7th rank, while relative_rank_bb(BLACK, 7) gives all squares on the 2nd
|
||||
/// rank.
|
||||
|
||||
inline Bitboard relative_rank_bb(Color c, Rank r) {
|
||||
return RelativeRankBB[c][r];
|
||||
}
|
||||
|
||||
|
||||
/// in_front_bb() takes a color and a rank or square as input, and returns a
|
||||
/// bitboard representing all the squares on all ranks in front of the rank
|
||||
/// (or square), from the given color's point of view. For instance,
|
||||
|
|
|
@ -446,8 +446,8 @@ ScaleFactor ScalingFunction<KQKRPs>::apply(const Position& pos) const {
|
|||
Square kingSq = pos.king_square(weakerSide);
|
||||
if ( relative_rank(weakerSide, kingSq) <= RANK_2
|
||||
&& relative_rank(weakerSide, pos.king_square(strongerSide)) >= RANK_4
|
||||
&& (pos.pieces(ROOK, weakerSide) & relative_rank_bb(weakerSide, RANK_3))
|
||||
&& (pos.pieces(PAWN, weakerSide) & relative_rank_bb(weakerSide, RANK_2))
|
||||
&& (pos.pieces(ROOK, weakerSide) & rank_bb(relative_rank(weakerSide, RANK_3)))
|
||||
&& (pos.pieces(PAWN, weakerSide) & rank_bb(relative_rank(weakerSide, RANK_2)))
|
||||
&& (pos.attacks_from<KING>(kingSq) & pos.pieces(PAWN, weakerSide)))
|
||||
{
|
||||
Square rsq = pos.piece_list(weakerSide, ROOK, 0);
|
||||
|
|
|
@ -544,7 +544,7 @@ inline bool Position::opposite_colored_bishops() const {
|
|||
}
|
||||
|
||||
inline bool Position::has_pawn_on_7th(Color c) const {
|
||||
return pieces(PAWN, c) & relative_rank_bb(c, RANK_7);
|
||||
return pieces(PAWN, c) & rank_bb(relative_rank(c, RANK_7));
|
||||
}
|
||||
|
||||
inline bool Position::is_chess960() const {
|
||||
|
|
29
src/square.h
29
src/square.h
|
@ -17,25 +17,15 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#if !defined(SQUARE_H_INCLUDED)
|
||||
#define SQUARE_H_INCLUDED
|
||||
|
||||
////
|
||||
//// Includes
|
||||
////
|
||||
|
||||
#include <cstdlib> // for abs()
|
||||
#include <string>
|
||||
|
||||
#include "color.h"
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
////
|
||||
//// Types
|
||||
////
|
||||
|
||||
enum Square {
|
||||
SQ_A1, SQ_B1, SQ_C1, SQ_D1, SQ_E1, SQ_F1, SQ_G1, SQ_H1,
|
||||
SQ_A2, SQ_B2, SQ_C2, SQ_D2, SQ_E2, SQ_F2, SQ_G2, SQ_H2,
|
||||
|
@ -49,11 +39,11 @@ enum Square {
|
|||
};
|
||||
|
||||
enum File {
|
||||
FILE_A, FILE_B, FILE_C, FILE_D, FILE_E, FILE_F, FILE_G, FILE_H, FILE_NONE
|
||||
FILE_A, FILE_B, FILE_C, FILE_D, FILE_E, FILE_F, FILE_G, FILE_H
|
||||
};
|
||||
|
||||
enum Rank {
|
||||
RANK_1, RANK_2, RANK_3, RANK_4, RANK_5, RANK_6, RANK_7, RANK_8, RANK_NONE
|
||||
RANK_1, RANK_2, RANK_3, RANK_4, RANK_5, RANK_6, RANK_7, RANK_8
|
||||
};
|
||||
|
||||
enum SquareDelta {
|
||||
|
@ -73,18 +63,9 @@ ENABLE_OPERATORS_ON(File)
|
|||
ENABLE_OPERATORS_ON(Rank)
|
||||
ENABLE_OPERATORS_ON(SquareDelta)
|
||||
|
||||
|
||||
////
|
||||
//// Constants
|
||||
////
|
||||
|
||||
const int FlipMask = 56;
|
||||
const int FlopMask = 7;
|
||||
|
||||
////
|
||||
//// Inline functions
|
||||
////
|
||||
|
||||
inline Square operator+ (Square x, SquareDelta i) { return x + Square(i); }
|
||||
inline void operator+= (Square& x, SquareDelta i) { x = x + Square(i); }
|
||||
inline Square operator- (Square x, SquareDelta i) { return x - Square(i); }
|
||||
|
@ -114,8 +95,12 @@ inline Square relative_square(Color c, Square s) {
|
|||
return Square(int(s) ^ (int(c) * FlipMask));
|
||||
}
|
||||
|
||||
inline Rank relative_rank(Color c, Rank r) {
|
||||
return Rank(int(r) ^ (int(c) * 7));
|
||||
}
|
||||
|
||||
inline Rank relative_rank(Color c, Square s) {
|
||||
return square_rank(relative_square(c, s));
|
||||
return relative_rank(c, square_rank(s));
|
||||
}
|
||||
|
||||
inline SquareColor square_color(Square s) {
|
||||
|
|
Loading…
Add table
Reference in a new issue