- Result classify_wtm(const KPKPosition &p) {
-
- // 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 as
- // RESULT_DRAW. Otherwise, the current position is classified as
- // RESULT_UNKNOWN.
-
- bool unknownFound = false;
- Bitboard b;
- Square s;
-
- // King moves
- b = p.wk_attacks();
- while(b) {
- s = pop_1st_bit(&b);
- switch(Bitbase[compute_index(s, p.blackKingSquare, p.pawnSquare,
- BLACK)]) {
- case RESULT_LOSS:
- return RESULT_WIN;
-
- case RESULT_UNKNOWN:
- unknownFound = true;
- break;
-
- case RESULT_DRAW: case RESULT_INVALID:
- break;
-
- default:
- assert(false);
- }
- }
-
- // Pawn moves
- if(square_rank(p.pawnSquare) < RANK_7) {
- s = p.pawnSquare + DELTA_N;
- switch(Bitbase[compute_index(p.whiteKingSquare, p.blackKingSquare, s,
- BLACK)]) {
- case RESULT_LOSS:
- return RESULT_WIN;
-
- case RESULT_UNKNOWN:
- unknownFound = true;
- break;
-
- case RESULT_DRAW: case RESULT_INVALID:
- break;
-
- default:
- assert(false);
- }
-
- if(square_rank(s) == RANK_3 &&
- s != p.whiteKingSquare && s != p.blackKingSquare) {
- s += DELTA_N;
- switch(Bitbase[compute_index(p.whiteKingSquare, p.blackKingSquare, s,
- BLACK)]) {
- case RESULT_LOSS:
- return RESULT_WIN;
-
- case RESULT_UNKNOWN:
- unknownFound = true;
- break;
-
- case RESULT_DRAW: case RESULT_INVALID:
- break;
-
- default:
- assert(false);
- }
- }
- }
-
- return unknownFound? RESULT_UNKNOWN : RESULT_DRAW;
- }
-
+ // White to Move: If one move leads to a position classified as RESULT_WIN,
+ // 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.
+ //
+ // Black to Move: If one move leads to a position classified as RESULT_DRAW,
+ // the result of the current position is RESULT_DRAW. If all moves lead to
+ // positions classified as RESULT_WIN, the position is classified RESULT_WIN.
+ // Otherwise, the current position is classified as RESULT_UNKNOWN.