- // Case 2: King can capture pawn
- if (bit_is_set(bka, pawnSquare) && !bit_is_set(wka, pawnSquare))
- return true;
- }
- else
- {
- // Case 1: Stalemate (possible pawn files are only from A to D)
- if ( whiteKingSquare == SQ_A8
- && pawnSquare == SQ_A7
- && (blackKingSquare == SQ_C7 || blackKingSquare == SQ_C8))
- return true;
- }
- return false;
- }
-
- bool KPKPosition::is_immediate_win() const {
-
- // The position is an immediate win if it is white to move and the
- // white pawn can be promoted without getting captured.
- return sideToMove == WHITE
- && square_rank(pawnSquare) == RANK_7
- && whiteKingSquare != pawnSquare + DELTA_N
- && ( square_distance(blackKingSquare, pawnSquare + DELTA_N) > 1
- || bit_is_set(wk_attacks(), pawnSquare + DELTA_N));
- }
-
- Result classify_wtm(const KPKPosition& pos, const Result bb[]) {
-
- // If one move leads to a position classified as RESULT_LOSS, the result
- // of the current position is RESULT_WIN. If all moves lead to positions
- // classified as RESULT_DRAW, the current position is classified RESULT_DRAW
- // otherwise the current position is classified as RESULT_UNKNOWN.
-
- bool unknownFound = false;
- Bitboard b;
- Square s;
- Result r;