To be uniform across the sources. As a nice side effect
I quickly spotted a couple of needed renames:
captured_piece() -> captured_piece_type()
st->capture -> st->capturedType
Proposed by Ralph and done with QtCreator
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
//
// We use NO_PIECE_TYPE as a place holder for the bishop pair "extended piece",
// this allow us to be more flexible in defining bishop pair bonuses.
//
// We use NO_PIECE_TYPE as a place holder for the bishop pair "extended piece",
// this allow us to be more flexible in defining bishop pair bonuses.
- for (pt1 = NO_PIECE_TYPE; pt1 <= QUEEN; pt1++)
+ for (pt1 = PIECE_TYPE_NONE; pt1 <= QUEEN; pt1++)
{
pc = pieceCount[c][pt1];
if (!pc)
{
pc = pieceCount[c][pt1];
if (!pc)
vv = LinearCoefficients[pt1];
vv = LinearCoefficients[pt1];
- for (pt2 = NO_PIECE_TYPE; pt2 <= pt1; pt2++)
+ for (pt2 = PIECE_TYPE_NONE; pt2 <= pt1; pt2++)
vv += pieceCount[c][pt2] * QuadraticCoefficientsSameColor[pt1][pt2]
+ pieceCount[them][pt2] * QuadraticCoefficientsOppositeColor[pt1][pt2];
vv += pieceCount[c][pt2] * QuadraticCoefficientsSameColor[pt1][pt2]
+ pieceCount[them][pt2] * QuadraticCoefficientsOppositeColor[pt1][pt2];
size_t idx = PieceChars.find(c);
size_t idx = PieceChars.find(c);
- return idx != string::npos ? PieceType(idx % 7) : NO_PIECE_TYPE;
+ return idx != string::npos ? PieceType(idx % 7) : PIECE_TYPE_NONE;
PAWN = 1, KNIGHT = 2, BISHOP = 3, ROOK = 4, QUEEN = 5, KING = 6
};
enum Piece {
PAWN = 1, KNIGHT = 2, BISHOP = 3, ROOK = 4, QUEEN = 5, KING = 6
};
enum Piece {
- NO_PIECE_DARK_SQ = 0, WP = 1, WN = 2, WB = 3, WR = 4, WQ = 5, WK = 6,
- BP = 9, BN = 10, BB = 11, BR = 12, BQ = 13, BK = 14, NO_PIECE = 16
+ PIECE_NONE_DARK_SQ = 0, WP = 1, WN = 2, WB = 3, WR = 4, WQ = 5, WK = 6,
+ BP = 9, BN = 10, BB = 11, BR = 12, BQ = 13, BK = 14, PIECE_NONE = 16
operator[]('B') = WB; operator[]('b') = BB;
operator[]('N') = WN; operator[]('n') = BN;
operator[]('P') = WP; operator[]('p') = BP;
operator[]('B') = WB; operator[]('b') = BB;
operator[]('N') = WN; operator[]('n') = BN;
operator[]('P') = WP; operator[]('p') = BP;
- operator[](' ') = NO_PIECE; operator[]('.') = NO_PIECE_DARK_SQ;
+ operator[](' ') = PIECE_NONE; operator[]('.') = PIECE_NONE_DARK_SQ;
}
char from_piece(Piece p) const {
}
char from_piece(Piece p) const {
fen.erase(--fen.end());
fen += (sideToMove == WHITE ? " w " : " b ");
fen.erase(--fen.end());
fen += (sideToMove == WHITE ? " w " : " b ");
- if (st->castleRights != NO_CASTLES)
+ if (st->castleRights != CASTLES_NONE)
{
const bool Chess960 = initialKFile != FILE_E
|| initialQRFile != FILE_A
{
const bool Chess960 = initialKFile != FILE_E
|| initialQRFile != FILE_A
char c = (color_of_piece_on(sq) == BLACK ? '=' : ' ');
Piece piece = piece_on(sq);
char c = (color_of_piece_on(sq) == BLACK ? '=' : ' ');
Piece piece = piece_on(sq);
- if (piece == NO_PIECE && square_color(sq) == DARK)
- piece = NO_PIECE_DARK_SQ;
+ if (piece == PIECE_NONE && square_color(sq) == DARK)
+ piece = PIECE_NONE_DARK_SQ;
cout << c << pieceLetters.from_piece(piece) << c << '|';
}
cout << c << pieceLetters.from_piece(piece) << c << '|';
}
assert(to == ep_square());
assert(piece_on(from) == piece_of_color_and_type(us, PAWN));
assert(piece_on(capsq) == piece_of_color_and_type(them, PAWN));
assert(to == ep_square());
assert(piece_on(from) == piece_of_color_and_type(us, PAWN));
assert(piece_on(capsq) == piece_of_color_and_type(them, PAWN));
- assert(piece_on(to) == NO_PIECE);
+ assert(piece_on(to) == PIECE_NONE);
clear_bit(&b, from);
clear_bit(&b, capsq);
clear_bit(&b, from);
clear_bit(&b, capsq);
do_move_bb(&(byTypeBB[0]), move_bb); // HACK: byTypeBB[0] == occupied squares
board[to] = board[from];
do_move_bb(&(byTypeBB[0]), move_bb); // HACK: byTypeBB[0] == occupied squares
board[to] = board[from];
- board[from] = NO_PIECE;
+ board[from] = PIECE_NONE;
// Update piece lists, note that index[from] is not updated and
// becomes stale. This works as long as index[] is accessed just
// Update piece lists, note that index[from] is not updated and
// becomes stale. This works as long as index[] is accessed just
st->value += pst_delta(piece, from, to);
// Set capture piece
st->value += pst_delta(piece, from, to);
// Set capture piece
+ st->capturedType = capture;
// Update the key with the final value
st->key = key;
// Update the key with the final value
st->key = key;
assert(to == st->epSquare);
assert(relative_rank(opposite_color(them), to) == RANK_6);
assert(to == st->epSquare);
assert(relative_rank(opposite_color(them), to) == RANK_6);
- assert(piece_on(to) == NO_PIECE);
+ assert(piece_on(to) == PIECE_NONE);
assert(piece_on(capsq) == piece_of_color_and_type(them, PAWN));
assert(piece_on(capsq) == piece_of_color_and_type(them, PAWN));
- board[capsq] = NO_PIECE;
+ board[capsq] = PIECE_NONE;
}
st->pawnKey ^= zobrist[them][PAWN][capsq];
}
}
st->pawnKey ^= zobrist[them][PAWN][capsq];
}
Color them = opposite_color(us);
// Reset capture field
Color them = opposite_color(us);
// Reset capture field
- st->capture = NO_PIECE_TYPE;
+ st->capturedType = PIECE_TYPE_NONE;
// Find source squares for king and rook
Square kfrom = move_from(m);
// Find source squares for king and rook
Square kfrom = move_from(m);
// Update board array
Piece king = piece_of_color_and_type(us, KING);
Piece rook = piece_of_color_and_type(us, ROOK);
// Update board array
Piece king = piece_of_color_and_type(us, KING);
Piece rook = piece_of_color_and_type(us, ROOK);
- board[kfrom] = board[rfrom] = NO_PIECE;
+ board[kfrom] = board[rfrom] = PIECE_NONE;
board[kto] = king;
board[rto] = rook;
board[kto] = king;
board[rto] = rook;
do_move_bb(&(byTypeBB[0]), move_bb); // HACK: byTypeBB[0] == occupied squares
board[from] = piece_of_color_and_type(us, pt);
do_move_bb(&(byTypeBB[0]), move_bb); // HACK: byTypeBB[0] == occupied squares
board[from] = piece_of_color_and_type(us, pt);
+ board[to] = PIECE_NONE;
// Update piece list
index[from] = index[to];
pieceList[us][pt][index[from]] = from;
// Update piece list
index[from] = index[to];
pieceList[us][pt][index[from]] = from;
{
Square capsq = to;
if (ep)
capsq = (us == WHITE)? (to - DELTA_N) : (to - DELTA_S);
{
Square capsq = to;
if (ep)
capsq = (us == WHITE)? (to - DELTA_N) : (to - DELTA_S);
- assert(st->capture != KING);
+ assert(st->capturedType != KING);
assert(!ep || square_is_empty(capsq));
// Restore the captured piece
set_bit(&(byColorBB[them]), capsq);
assert(!ep || square_is_empty(capsq));
// Restore the captured piece
set_bit(&(byColorBB[them]), capsq);
- set_bit(&(byTypeBB[st->capture]), capsq);
+ set_bit(&(byTypeBB[st->capturedType]), capsq);
set_bit(&(byTypeBB[0]), capsq);
set_bit(&(byTypeBB[0]), capsq);
- board[capsq] = piece_of_color_and_type(them, st->capture);
+ board[capsq] = piece_of_color_and_type(them, st->capturedType);
- pieceCount[them][st->capture]++;
+ pieceCount[them][st->capturedType]++;
// Update piece list, add a new captured piece in capsq square
// Update piece list, add a new captured piece in capsq square
- index[capsq] = pieceCount[them][st->capture] - 1;
- pieceList[them][st->capture][index[capsq]] = capsq;
+ index[capsq] = pieceCount[them][st->capturedType] - 1;
+ pieceList[them][st->capturedType][index[capsq]] = capsq;
}
// Finally point our state pointer back to the previous state
}
// Finally point our state pointer back to the previous state
set_bit(&(byTypeBB[0]), rfrom); // HACK: byTypeBB[0] == occupied squares
// Update board
set_bit(&(byTypeBB[0]), rfrom); // HACK: byTypeBB[0] == occupied squares
// Update board
- board[rto] = board[kto] = NO_PIECE;
+ board[rto] = board[kto] = PIECE_NONE;
board[rfrom] = piece_of_color_and_type(us, ROOK);
board[kfrom] = piece_of_color_and_type(us, KING);
board[rfrom] = piece_of_color_and_type(us, ROOK);
board[kfrom] = piece_of_color_and_type(us, KING);
// Handle en passant moves
if (st->epSquare == to && type_of_piece_on(from) == PAWN)
{
// Handle en passant moves
if (st->epSquare == to && type_of_piece_on(from) == PAWN)
{
- assert(capture == NO_PIECE);
+ assert(capture == PIECE_NONE);
Square capQq = (side_to_move() == WHITE)? (to - DELTA_N) : (to - DELTA_S);
capture = piece_on(capQq);
Square capQq = (side_to_move() == WHITE)? (to - DELTA_N) : (to - DELTA_S);
capture = piece_on(capQq);
memset(index, 0, sizeof(int) * 64);
for (int i = 0; i < 64; i++)
memset(index, 0, sizeof(int) * 64);
for (int i = 0; i < 64; i++)
for (int i = 0; i < 8; i++)
for (int j = 0; j < 16; j++)
for (int i = 0; i < 8; i++)
for (int j = 0; j < 16; j++)
/// Castle rights, encoded as bit fields
enum CastleRights {
/// Castle rights, encoded as bit fields
enum CastleRights {
- NO_CASTLES = 0,
- WHITE_OO = 1,
- BLACK_OO = 2,
- WHITE_OOO = 4,
- BLACK_OOO = 8,
- ALL_CASTLES = 15
+ CASTLES_NONE = 0,
+ WHITE_OO = 1,
+ BLACK_OO = 2,
+ WHITE_OOO = 4,
+ BLACK_OOO = 8,
+ ALL_CASTLES = 15
Score value;
Value npMaterial[2];
Score value;
Value npMaterial[2];
+ PieceType capturedType;
Key key;
Bitboard checkersBB;
StateInfo* previous;
Key key;
Bitboard checkersBB;
StateInfo* previous;
bool move_attacks_square(Move m, Square s) const;
// Piece captured with previous moves
bool move_attacks_square(Move m, Square s) const;
// Piece captured with previous moves
- PieceType captured_piece() const;
+ PieceType captured_piece_type() const;
// Information about pawns
bool pawn_is_passed(Color c, Square s) const;
// Information about pawns
bool pawn_is_passed(Color c, Square s) const;
}
inline bool Position::square_is_empty(Square s) const {
}
inline bool Position::square_is_empty(Square s) const {
- return piece_on(s) == NO_PIECE;
+ return piece_on(s) == PIECE_NONE;
}
inline bool Position::square_is_occupied(Square s) const {
}
inline bool Position::square_is_occupied(Square s) const {
return (m & (0x1F << 12)) ? !move_is_castle(m) : !square_is_empty(move_to(m));
}
return (m & (0x1F << 12)) ? !move_is_castle(m) : !square_is_empty(move_to(m));
}
-inline PieceType Position::captured_piece() const {
- return st->capture;
+inline PieceType Position::captured_piece_type() const {
+ return st->capturedType;
}
inline int Position::thread() const {
}
inline int Position::thread() const {
// Normal moves. We use a simple FSM to parse the san string.
enum { START, TO_FILE, TO_RANK, PROMOTION_OR_CHECK, PROMOTION, CHECK, END };
static const string pieceLetters = "KQRBN";
// Normal moves. We use a simple FSM to parse the san string.
enum { START, TO_FILE, TO_RANK, PROMOTION_OR_CHECK, PROMOTION, CHECK, END };
static const string pieceLetters = "KQRBN";
- PieceType pt = NO_PIECE_TYPE, promotion = NO_PIECE_TYPE;
+ PieceType pt = PIECE_TYPE_NONE, promotion = PIECE_TYPE_NONE;
File fromFile = FILE_NONE, toFile = FILE_NONE;
Rank fromRank = RANK_NONE, toRank = RANK_NONE;
Square to;
File fromFile = FILE_NONE, toFile = FILE_NONE;
Rank fromRank = RANK_NONE, toRank = RANK_NONE;
Square to;
if ( m != MOVE_NULL
&& before != VALUE_NONE
&& after != VALUE_NONE
if ( m != MOVE_NULL
&& before != VALUE_NONE
&& after != VALUE_NONE
- && pos.captured_piece() == NO_PIECE_TYPE
+ && pos.captured_piece_type() == PIECE_TYPE_NONE
&& !move_is_special(m))
H.set_gain(pos.piece_on(move_to(m)), move_to(m), -(before + after));
}
&& !move_is_special(m))
H.set_gain(pos.piece_on(move_to(m)), move_to(m), -(before + after));
}