- 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;
- }
-
- if ((*step)++, ep_square() != SQ_NONE && relative_rank(sideToMove, ep_square()) != RANK_6)
- return false;
-
- if ((*step)++, debugKey && st->key != compute_key())
- return false;
-
- if ((*step)++, debugPawnKey && st->pawnKey != compute_pawn_key())
- return false;
-
- if ((*step)++, debugMaterialKey && st->materialKey != compute_material_key())
- return false;
-
- if ((*step)++, debugIncrementalEval && st->psq != compute_psq_score())
- return false;
-
- if ((*step)++, debugNonPawnMaterial)
- if ( st->npMaterial[WHITE] != compute_non_pawn_material(WHITE)
- || st->npMaterial[BLACK] != compute_non_pawn_material(BLACK))
- return false;
-
- if ((*step)++, debugPieceCounts)
- for (Color c = WHITE; c <= BLACK; c++)
- for (PieceType pt = PAWN; pt <= KING; pt++)
- if (pieceCount[c][pt] != popcount<Full>(pieces(c, pt)))
- return false;
-
- if ((*step)++, debugPieceList)
- for (Color c = WHITE; c <= BLACK; c++)
- for (PieceType pt = PAWN; pt <= KING; pt++)
- for (int i = 0; i < pieceCount[c][pt]; i++)
- if ( board[pieceList[c][pt][i]] != make_piece(c, pt)
- || index[pieceList[c][pt][i]] != i)
- return false;
-
- if ((*step)++, debugCastleSquares)
- for (Color c = WHITE; c <= BLACK; c++)
- for (CastlingSide s = KING_SIDE; s <= QUEEN_SIDE; s = CastlingSide(s + 1))
- {
- CastleRight cr = make_castle_right(c, s);
-
- if (!can_castle(cr))
- continue;