- // Case 1: Stalemate
- if ( sideToMove == BLACK
- && !(bk_attacks() & ~(wk_attacks() | pawn_attacks())))
- return RESULT_DRAW;
-
- // Case 2: King can capture pawn
- if ( sideToMove == BLACK
- && bit_is_set(bk_attacks(), pawnSquare) && !bit_is_set(wk_attacks(), pawnSquare))
- return RESULT_DRAW;
-
- // Case 3: Black king in front of white pawn
- if ( blackKingSquare == pawnSquare + DELTA_N
- && rank_of(pawnSquare) < RANK_7)
- return RESULT_DRAW;
-
- // Case 4: White king in front of pawn and black has opposition
- if ( whiteKingSquare == pawnSquare + DELTA_N
- && blackKingSquare == pawnSquare + DELTA_N + DELTA_N + DELTA_N
- && rank_of(pawnSquare) < RANK_5
- && sideToMove == WHITE)
- return RESULT_DRAW;
-
- // Case 5: Stalemate with rook pawn
- if ( blackKingSquare == SQ_A8
- && file_of(pawnSquare) == FILE_A)
- return RESULT_DRAW;
-
- return RESULT_UNKNOWN;
- }
-
- Result KPKPosition::classify(int index, Result db[]) {
+ // Black to Move: If one move leads to a position classified as DRAW, the result
+ // of the current position is DRAW. If all moves lead to positions classified
+ // as WIN, the position is classified WIN otherwise the current position is
+ // classified UNKNOWN.