X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=d00a531c0d5caa1d9e726171d0953ab37ac60f13;hp=3fc568eebf93a0e674d748ceee4095c8b92b7551;hb=cc3002ff0450e4f396cd95c0dcbf44bb66dab695;hpb=d2a8ba329940655e4683a67a2528a92717700732 diff --git a/src/position.cpp b/src/position.cpp index 3fc568ee..d00a531c 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -596,12 +596,11 @@ bool Position::gives_check(Move m, const CheckInfo& ci) const { && !aligned(from, to, ci.ksq)) return true; - // Can we skip the ugly special cases? - if (type_of(m) == NORMAL) - return false; - switch (type_of(m)) { + case NORMAL: + return false; + case PROMOTION: return attacks_bb(Piece(promotion_type(m)), to, pieces() ^ from) & ci.ksq; @@ -1264,9 +1263,7 @@ bool Position::pos_is_ok(int* failedStep) const { const bool debugPieceList = all || false; const bool debugCastlingSquares = all || false; - *step = 1; - - if (sideToMove != WHITE && sideToMove != BLACK) + if (*step = 1, sideToMove != WHITE && sideToMove != BLACK) return false; if ((*step)++, piece_on(king_square(WHITE)) != W_KING) @@ -1276,16 +1273,9 @@ bool Position::pos_is_ok(int* failedStep) const { return false; if ((*step)++, debugKingCount) - { - int kingCount[COLOR_NB] = {}; - - for (Square s = SQ_A1; s <= SQ_H8; ++s) - if (type_of(piece_on(s)) == KING) - ++kingCount[color_of(piece_on(s))]; - - if (kingCount[0] != 1 || kingCount[1] != 1) + if ( std::count(board, board + SQUARE_NB, W_KING) != 1 + || std::count(board, board + SQUARE_NB, B_KING) != 1) return false; - } if ((*step)++, debugKingCapture) if (attackers_to(king_square(~sideToMove)) & pieces(sideToMove))