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;
}
char from_piece(Piece p) const {
Score Position::PieceSquareTable[16][64];
-static bool RequestPending = false;
static PieceLetters pieceLetters;
/// Position::print() prints an ASCII representation of the position to
/// the standard output. If a move is given then also the san is print.
-void Position::print(Move m) const {
+void Position::print(Move move) const {
- static const string pieceLetters = " PNBRQK PNBRQK .";
+ const char* dottedLine = "\n+---+---+---+---+---+---+---+---+\n";
+ static bool requestPending = false;
// Check for reentrancy, as example when called from inside
// MovePicker that is used also here in move_to_san()
- if (RequestPending)
+ if (requestPending)
return;
- RequestPending = true;
+ requestPending = true;
- cout << endl;
- if (m != MOVE_NONE)
+ if (move)
{
Position p(*this, thread());
- string col = (color_of_piece_on(move_from(m)) == BLACK ? ".." : "");
- cout << "Move is: " << col << move_to_san(p, m) << endl;
+ string dd = (color_of_piece_on(move_from(move)) == BLACK ? ".." : "");
+ cout << "\nMove is: " << dd << move_to_san(p, move);
}
+
for (Rank rank = RANK_8; rank >= RANK_1; rank--)
{
- cout << "+---+---+---+---+---+---+---+---+" << endl;
+ cout << dottedLine << '|';
for (File file = FILE_A; file <= FILE_H; file++)
{
Square sq = make_square(file, rank);
+ char c = (color_of_piece_on(sq) == BLACK ? '=' : ' ');
Piece piece = piece_on(sq);
- if (piece == EMPTY && square_color(sq) == WHITE)
- piece = NO_PIECE;
- char col = (color_of_piece_on(sq) == BLACK ? '=' : ' ');
- cout << '|' << col << pieceLetters[piece] << col;
+ if (piece == NO_PIECE && square_color(sq) == DARK)
+ piece = NO_PIECE_DARK_SQ;
+
+ cout << c << pieceLetters.from_piece(piece) << c << '|';
}
- cout << '|' << endl;
}
- cout << "+---+---+---+---+---+---+---+---+" << endl
- << "Fen is: " << to_fen() << endl
- << "Key is: " << st->key << endl;
-
- RequestPending = false;
+ cout << dottedLine << "Fen is: " << to_fen() << "\nKey is: " << st->key << endl;
+ requestPending = false;
}
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) == EMPTY);
+ assert(piece_on(to) == NO_PIECE);
clear_bit(&b, from);
clear_bit(&b, capsq);
do_move_bb(&(byTypeBB[0]), move_bb); // HACK: byTypeBB[0] == occupied squares
board[to] = board[from];
- board[from] = EMPTY;
+ board[from] = NO_PIECE;
// Update piece lists, note that index[from] is not updated and
// becomes stale. This works as long as index[] is accessed just
assert(to == st->epSquare);
assert(relative_rank(opposite_color(them), to) == RANK_6);
- assert(piece_on(to) == EMPTY);
+ assert(piece_on(to) == NO_PIECE);
assert(piece_on(capsq) == piece_of_color_and_type(them, PAWN));
- board[capsq] = EMPTY;
+ board[capsq] = NO_PIECE;
}
st->pawnKey ^= zobrist[them][PAWN][capsq];
}
// 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] = EMPTY;
+ board[kfrom] = board[rfrom] = NO_PIECE;
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);
- board[to] = EMPTY;
+ board[to] = NO_PIECE;
// Update piece list
index[from] = index[to];
set_bit(&(byTypeBB[0]), rfrom); // HACK: byTypeBB[0] == occupied squares
// Update board
- board[rto] = board[kto] = EMPTY;
+ board[rto] = board[kto] = NO_PIECE;
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)
{
- assert(capture == EMPTY);
+ assert(capture == NO_PIECE);
Square capQq = (side_to_move() == WHITE)? (to - DELTA_N) : (to - DELTA_S);
capture = piece_on(capQq);
st = &startState;
memset(st, 0, sizeof(StateInfo));
st->epSquare = SQ_NONE;
+ startPosPlyCounter = 0;
memset(byColorBB, 0, sizeof(Bitboard) * 2);
memset(byTypeBB, 0, sizeof(Bitboard) * 8);
memset(index, 0, sizeof(int) * 64);
for (int i = 0; i < 64; i++)
- board[i] = EMPTY;
+ board[i] = NO_PIECE;
for (int i = 0; i < 8; i++)
for (int j = 0; j < 16; j++)
st->gamePly = 0;
}
+void Position::inc_startpos_ply_counter() {
+
+ startPosPlyCounter++;
+}
/// Position::put_piece() puts a piece on the given square of the board,
/// updating the board array, bitboards, and piece counts.