/// Position::print() prints an ASCII representation of the position to
-/// the standard output. If a move is given then also the san is print.
+/// the standard output. If a move is given then also the san is printed.
void Position::print(Move move) const {
assert(move_is_ok(m));
assert(square_is_ok(s));
+ Bitboard occ, xray;
Square f = move_from(m), t = move_to(m);
assert(square_is_occupied(f));
return true;
// Move the piece and scan for X-ray attacks behind it
- Bitboard occ = occupied_squares();
- Color us = color_of_piece_on(f);
- clear_bit(&occ, f);
- set_bit(&occ, t);
- Bitboard xray = ( (rook_attacks_bb(s, occ) & pieces(ROOK, QUEEN))
- |(bishop_attacks_bb(s, occ) & pieces(BISHOP, QUEEN))) & pieces_of_color(us);
+ occ = occupied_squares();
+ do_move_bb(&occ, make_move_bb(f, t));
+ xray = ( (rook_attacks_bb(s, occ) & pieces(ROOK, QUEEN))
+ |(bishop_attacks_bb(s, occ) & pieces(BISHOP, QUEEN)))
+ & pieces_of_color(color_of_piece_on(f));
// If we have attacks we need to verify that are caused by our move
// and are not already existent ones.
Key Position::compute_key() const {
- Key result = Key(0ULL);
+ Key result = 0;
for (Square s = SQ_A1; s <= SQ_H8; s++)
if (square_is_occupied(s))
Key Position::compute_pawn_key() const {
- Key result = Key(0ULL);
+ Key result = 0;
Bitboard b;
Square s;
Key Position::compute_material_key() const {
- Key result = Key(0ULL);
+ Key result = 0;
for (Color c = WHITE; c <= BLACK; c++)
for (PieceType pt = PAWN; pt <= QUEEN; pt++)
{
bool Position::is_mate() const {
- MoveStack moves[256];
+ MoveStack moves[MOVES_MAX];
return is_check() && (generate_moves(*this, moves) == moves);
}
bool Position::has_mate_threat() {
- MoveStack mlist[256], *last, *cur;
+ MoveStack mlist[MOVES_MAX], *last, *cur;
StateInfo st1, st2;
bool mateFound = false;
// Is there more than 2 checkers?
if (failedStep) (*failedStep)++;
- if (debugCheckerCount && count_1s(st->checkersBB) > 2)
+ if (debugCheckerCount && count_1s<CNT32>(st->checkersBB) > 2)
return false;
// Bitboards OK?
if (debugPieceCounts)
for (Color c = WHITE; c <= BLACK; c++)
for (PieceType pt = PAWN; pt <= KING; pt++)
- if (pieceCount[c][pt] != count_1s(pieces(pt, c)))
+ if (pieceCount[c][pt] != count_1s<CNT32>(pieces(pt, c)))
return false;
if (failedStep) (*failedStep)++;