-bool Position::pos_is_ok(int* failedStep) const {
-
- int dummy, *step = failedStep ? failedStep : &dummy;
-
- // What features of the position should be verified?
- const bool all = false;
-
- const bool debugBitboards = all || false;
- const bool debugKingCount = all || false;
- const bool debugKingCapture = all || false;
- const bool debugCheckerCount = all || false;
- const bool debugKey = all || false;
- const bool debugMaterialKey = all || false;
- const bool debugPawnKey = all || false;
- const bool debugIncrementalEval = all || false;
- const bool debugNonPawnMaterial = all || false;
- const bool debugPieceCounts = all || false;
- const bool debugPieceList = all || false;
- const bool debugCastlingSquares = all || false;
-
- *step = 1;
-
- if (sideToMove != WHITE && sideToMove != BLACK)
- return false;
-
- if ((*step)++, piece_on(king_square(WHITE)) != W_KING)
- return false;
-
- if ((*step)++, piece_on(king_square(BLACK)) != B_KING)
- 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)
- return false;
- }
-
- if ((*step)++, debugKingCapture)
- if (attackers_to(king_square(~sideToMove)) & pieces(sideToMove))
- return false;
-
- if ((*step)++, debugCheckerCount && popcount<Full>(st->checkersBB) > 2)
- return false;
-
- if ((*step)++, debugBitboards)
- {
- // The intersection of the white and black pieces must be empty
- if (pieces(WHITE) & pieces(BLACK))
- return false;
-
- // The union of the white and black pieces must be equal to all
- // occupied squares
- if ((pieces(WHITE) | pieces(BLACK)) != pieces())
- return false;
-
- // Separate piece type bitboards must have empty intersections
- for (PieceType p1 = PAWN; p1 <= KING; ++p1)
- for (PieceType p2 = PAWN; p2 <= KING; ++p2)
- if (p1 != p2 && (pieces(p1) & pieces(p2)))
- return false;
- }