No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
// kbnk_mate_table() tries to drive toward corners A1 or H8,
// if we have a bishop that cannot reach the above squares we
// mirror the kings so to drive enemy toward corners A8 or H1.
// kbnk_mate_table() tries to drive toward corners A1 or H8,
// if we have a bishop that cannot reach the above squares we
// mirror the kings so to drive enemy toward corners A8 or H1.
- if (opposite_color_squares(bishopSquare, SQ_A1))
+ if (opposite_colors(bishopSquare, SQ_A1))
{
winnerKSq = mirror(winnerKSq);
loserKSq = mirror(loserKSq);
{
winnerKSq = mirror(winnerKSq);
loserKSq = mirror(loserKSq);
Square queeningSq = relative_square(strongerSide, make_square(pawnFile, RANK_8));
Square kingSq = pos.king_square(weakerSide);
Square queeningSq = relative_square(strongerSide, make_square(pawnFile, RANK_8));
Square kingSq = pos.king_square(weakerSide);
- if ( opposite_color_squares(queeningSq, bishopSq)
+ if ( opposite_colors(queeningSq, bishopSq)
&& abs(file_of(kingSq) - pawnFile) <= 1)
{
// The bishop has the wrong color, and the defending king is on the
&& abs(file_of(kingSq) - pawnFile) <= 1)
{
// The bishop has the wrong color, and the defending king is on the
// Case 1: Defending king blocks the pawn, and cannot be driven away
if ( file_of(weakerKingSq) == file_of(pawnSq)
&& relative_rank(strongerSide, pawnSq) < relative_rank(strongerSide, weakerKingSq)
// Case 1: Defending king blocks the pawn, and cannot be driven away
if ( file_of(weakerKingSq) == file_of(pawnSq)
&& relative_rank(strongerSide, pawnSq) < relative_rank(strongerSide, weakerKingSq)
- && ( opposite_color_squares(weakerKingSq, strongerBishopSq)
+ && ( opposite_colors(weakerKingSq, strongerBishopSq)
|| relative_rank(strongerSide, weakerKingSq) <= RANK_6))
return SCALE_FACTOR_ZERO;
// Case 2: Opposite colored bishops
|| relative_rank(strongerSide, weakerKingSq) <= RANK_6))
return SCALE_FACTOR_ZERO;
// Case 2: Opposite colored bishops
- if (opposite_color_squares(strongerBishopSq, weakerBishopSq))
+ if (opposite_colors(strongerBishopSq, weakerBishopSq))
{
// We assume that the position is drawn in the following three situations:
//
{
// We assume that the position is drawn in the following three situations:
//
Square wbsq = pos.piece_list(strongerSide, BISHOP)[0];
Square bbsq = pos.piece_list(weakerSide, BISHOP)[0];
Square wbsq = pos.piece_list(strongerSide, BISHOP)[0];
Square bbsq = pos.piece_list(weakerSide, BISHOP)[0];
- if (!opposite_color_squares(wbsq, bbsq))
+ if (!opposite_colors(wbsq, bbsq))
return SCALE_FACTOR_NONE;
Square ksq = pos.king_square(weakerSide);
return SCALE_FACTOR_NONE;
Square ksq = pos.king_square(weakerSide);
// some square in the frontmost pawn's path.
if ( file_of(ksq) == file_of(blockSq1)
&& relative_rank(strongerSide, ksq) >= relative_rank(strongerSide, blockSq1)
// some square in the frontmost pawn's path.
if ( file_of(ksq) == file_of(blockSq1)
&& relative_rank(strongerSide, ksq) >= relative_rank(strongerSide, blockSq1)
- && opposite_color_squares(ksq, wbsq))
+ && opposite_colors(ksq, wbsq))
return SCALE_FACTOR_ZERO;
else
return SCALE_FACTOR_NONE;
return SCALE_FACTOR_ZERO;
else
return SCALE_FACTOR_NONE;
// in front of the frontmost pawn's path, and the square diagonally behind
// this square on the file of the other pawn.
if ( ksq == blockSq1
// in front of the frontmost pawn's path, and the square diagonally behind
// this square on the file of the other pawn.
if ( ksq == blockSq1
- && opposite_color_squares(ksq, wbsq)
+ && opposite_colors(ksq, wbsq)
&& ( bbsq == blockSq2
|| (pos.attacks_from<BISHOP>(blockSq2) & pos.pieces(BISHOP, weakerSide))
|| abs(r1 - r2) >= 2))
return SCALE_FACTOR_ZERO;
else if ( ksq == blockSq2
&& ( bbsq == blockSq2
|| (pos.attacks_from<BISHOP>(blockSq2) & pos.pieces(BISHOP, weakerSide))
|| abs(r1 - r2) >= 2))
return SCALE_FACTOR_ZERO;
else if ( ksq == blockSq2
- && opposite_color_squares(ksq, wbsq)
+ && opposite_colors(ksq, wbsq)
&& ( bbsq == blockSq1
|| (pos.attacks_from<BISHOP>(blockSq1) & pos.pieces(BISHOP, weakerSide))))
return SCALE_FACTOR_ZERO;
&& ( bbsq == blockSq1
|| (pos.attacks_from<BISHOP>(blockSq1) & pos.pieces(BISHOP, weakerSide))))
return SCALE_FACTOR_ZERO;
if ( file_of(weakerKingSq) == file_of(pawnSq)
&& relative_rank(strongerSide, pawnSq) < relative_rank(strongerSide, weakerKingSq)
if ( file_of(weakerKingSq) == file_of(pawnSq)
&& relative_rank(strongerSide, pawnSq) < relative_rank(strongerSide, weakerKingSq)
- && ( opposite_color_squares(weakerKingSq, strongerBishopSq)
+ && ( opposite_colors(weakerKingSq, strongerBishopSq)
|| relative_rank(strongerSide, weakerKingSq) <= RANK_6))
return SCALE_FACTOR_ZERO;
|| relative_rank(strongerSide, weakerKingSq) <= RANK_6))
return SCALE_FACTOR_ZERO;
if (bonus && bit_is_set(ei.attackedBy[Us][PAWN], s))
{
if ( pos.pieces(KNIGHT, Them) == EmptyBoardBB
if (bonus && bit_is_set(ei.attackedBy[Us][PAWN], s))
{
if ( pos.pieces(KNIGHT, Them) == EmptyBoardBB
- && (SquaresByColorBB[square_color(s)] & pos.pieces(BISHOP, Them)) == EmptyBoardBB)
+ && (SquaresByColorBB[color_of(s)] & pos.pieces(BISHOP, Them)) == EmptyBoardBB)
bonus += bonus + bonus / 2;
else
bonus += bonus / 2;
bonus += bonus + bonus / 2;
else
bonus += bonus / 2;
Square sq = make_square(file, rank);
Piece piece = piece_on(sq);
Square sq = make_square(file, rank);
Piece piece = piece_on(sq);
- if (piece == PIECE_NONE && square_color(sq) == DARK)
+ if (piece == PIECE_NONE && color_of(sq) == DARK)
piece = PIECE_NONE_DARK_SQ;
char c = (color_of(piece_on(sq)) == BLACK ? '=' : ' ');
piece = PIECE_NONE_DARK_SQ;
char c = (color_of(piece_on(sq)) == BLACK ? '=' : ' ');
}
inline bool Position::square_is_empty(Square s) const {
}
inline bool Position::square_is_empty(Square s) const {
- return piece_on(s) == PIECE_NONE;
+ return board[s] == PIECE_NONE;
}
inline Color Position::side_to_move() const {
}
inline Color Position::side_to_move() const {
}
inline Bitboard Position::empty_squares() const {
}
inline Bitboard Position::empty_squares() const {
- return ~occupied_squares();
}
inline Bitboard Position::pieces(Color c) const {
}
inline Bitboard Position::pieces(Color c) const {
}
inline bool Position::in_check() const {
}
inline bool Position::in_check() const {
- return st->checkersBB != EmptyBoardBB;
+ return st->checkersBB != 0;
}
inline bool Position::pawn_is_passed(Color c, Square s) const {
}
inline bool Position::pawn_is_passed(Color c, Square s) const {
inline bool Position::move_is_passed_pawn_push(Move m) const {
inline bool Position::move_is_passed_pawn_push(Move m) const {
- Color c = side_to_move();
- return piece_on(move_from(m)) == make_piece(c, PAWN)
- && pawn_is_passed(c, move_to(m));
+ return board[move_from(m)] == make_piece(sideToMove, PAWN)
+ && pawn_is_passed(sideToMove, move_to(m));
}
inline int Position::startpos_ply_counter() const {
}
inline int Position::startpos_ply_counter() const {
inline bool Position::opposite_colored_bishops() const {
inline bool Position::opposite_colored_bishops() const {
- return piece_count(WHITE, BISHOP) == 1
- && piece_count(BLACK, BISHOP) == 1
- && opposite_color_squares(piece_list(WHITE, BISHOP)[0], piece_list(BLACK, BISHOP)[0]);
+ return pieceCount[WHITE][BISHOP] == 1
+ && pieceCount[BLACK][BISHOP] == 1
+ && opposite_colors(pieceList[WHITE][BISHOP][0], pieceList[BLACK][BISHOP][0]);
}
inline bool Position::has_pawn_on_7th(Color c) const {
}
inline bool Position::has_pawn_on_7th(Color c) const {
-inline char piece_type_to_char(PieceType pt) {
- static const char ch[] = " PNBRQK";
- return ch[pt];
-}
-
inline Square make_square(File f, Rank r) {
return Square((r << 3) | f);
}
inline Square make_square(File f, Rank r) {
return Square((r << 3) | f);
}
return relative_rank(c, rank_of(s));
}
return relative_rank(c, rank_of(s));
}
-inline SquareColor square_color(Square s) {
+inline SquareColor color_of(Square s) {
return SquareColor(int(rank_of(s) + s) & 1);
}
return SquareColor(int(rank_of(s) + s) & 1);
}
-inline bool opposite_color_squares(Square s1, Square s2) {
+inline bool opposite_colors(Square s1, Square s2) {
int s = s1 ^ s2;
return ((s >> 3) ^ s) & 1;
}
int s = s1 ^ s2;
return ((s >> 3) ^ s) & 1;
}
return SquareDistance[s1][s2];
}
return SquareDistance[s1][s2];
}
+inline char piece_type_to_char(PieceType pt) {
+ return " PNBRQK"[pt];
+}
+
inline char file_to_char(File f) {
return char(f - FILE_A + int('a'));
}
inline char file_to_char(File f) {
return char(f - FILE_A + int('a'));
}
inline const std::string square_to_string(Square s) {
char ch[] = { file_to_char(file_of(s)), rank_to_char(rank_of(s)), 0 };
inline const std::string square_to_string(Square s) {
char ch[] = { file_to_char(file_of(s)), rank_to_char(rank_of(s)), 0 };
- return std::string(ch);
}
inline Square pawn_push(Color c) {
}
inline Square pawn_push(Color c) {