X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=8667d44bfce718500aadc73cd16fe8db34d72763;hp=d7e0516c88114007d0ee26473a8ed4b16630668e;hb=f7ef48b4780e86d794d9bccbb2d0e2b8d346fa32;hpb=2ff2b5972799c2cb1b68e2d82e35b9b3c7c6996d diff --git a/src/position.cpp b/src/position.cpp index d7e0516c..8667d44b 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -501,7 +501,7 @@ Bitboard Position::attacks_from(Piece p, Square s) const { case WB: case BB: return attacks_from(s); case WR: case BR: return attacks_from(s); case WQ: case BQ: return attacks_from(s); - default: return NonSlidingAttacksBB[p][s]; + default: return StepAttacksBB[p][s]; } } @@ -514,7 +514,7 @@ Bitboard Position::attacks_from(Piece p, Square s, Bitboard occ) { case WB: case BB: return bishop_attacks_bb(s, occ); case WR: case BR: return rook_attacks_bb(s, occ); case WQ: case BQ: return bishop_attacks_bb(s, occ) | rook_attacks_bb(s, occ); - default: return NonSlidingAttacksBB[p][s]; + default: return StepAttacksBB[p][s]; } } @@ -1712,7 +1712,7 @@ bool Position::has_mate_threat() { // Loop through the moves, and see if one of them gives mate Bitboard pinned = pinned_pieces(sideToMove); CheckInfo ci(*this); - for (cur = mlist; cur != last && !mateFound; cur++) + for (cur = mlist; !mateFound && cur != last; cur++) { Move move = cur->move; if ( !pl_move_is_legal(move, pinned) @@ -1720,10 +1720,7 @@ bool Position::has_mate_threat() { continue; do_move(move, st2, ci, true); - - if (is_mate()) - mateFound = true; - + mateFound = is_mate(); undo_move(move); } @@ -1975,7 +1972,6 @@ bool Position::is_ok(int* failedStep) const { if (failedStep) (*failedStep)++; if (debugPieceList) - { for (Color c = WHITE; c <= BLACK; c++) for (PieceType pt = PAWN; pt <= KING; pt++) for (int i = 0; i < pieceCount[c][pt]; i++) @@ -1986,13 +1982,15 @@ bool Position::is_ok(int* failedStep) const { if (index[piece_list(c, pt, i)] != i) return false; } - } if (failedStep) (*failedStep)++; - if (debugCastleSquares) { - for (Color c = WHITE; c <= BLACK; c++) { + if (debugCastleSquares) + { + for (Color c = WHITE; c <= BLACK; c++) + { if (can_castle_kingside(c) && piece_on(initial_kr_square(c)) != make_piece(c, ROOK)) return false; + if (can_castle_queenside(c) && piece_on(initial_qr_square(c)) != make_piece(c, ROOK)) return false; }