- bool KPKPosition::is_immediate_draw() const {
-
- if (sideToMove == BLACK)
- {
- Bitboard wka = wk_attacks();
- Bitboard bka = bk_attacks();
-
- // Case 1: Stalemate
- if ((bka & ~(wka | pawn_attacks())) == EmptyBoardBB)
- return true;
-
- // Case 2: King can capture pawn
- if (bit_is_set(bka, pawnSquare) && !bit_is_set(wka, pawnSquare))
- return true;
- }
- else
- {
- // Case 1: Stalemate
- 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
- && ( square_distance(blackKingSquare, pawnSquare + DELTA_N) > 1
- || bit_is_set(wk_attacks(), pawnSquare + DELTA_N));
- }