KPK - peregrineshahin/ChessProgrammingWiki GitHub Wiki


title: KPK

Home * Evaluation * Game Phases * Endgame * Pawn Endgame * KPK

A very common pattern in chess games is to be up exactly one pawn and then try to trade down to a won KP vs K endgame. So this is a very fundamental ending that good chess programs should understand.

Perfect Heuristics

This ending can also be determined perfectly with a set of heuristics [1].

Imperfect Heuristics

There is also an imperfect solution that yields reasonably good results - using interior node recognizers detecting positions that are obviously won or drawn, but leaving "unclear" positions to evaluation and/or further search. An example of such a set of heuristics is given below:

KPK is drawn

  • In the case that the pawn can be immediately captured, might be delegated to the quiescence search
  • Defending king stands directly in front of the pawn, the other king - directly behind it, weaker side to move
  • Defending king as above, the other king diagonally behind the pawn, stronger side to move
  • Kings stand in the vertical opposition and the pawn is on the right/left side of the king of the stronger side, which is about to move
  • In the above position the stronger side moves a pawn, giving check
  • Assuming the squares are numbered 0..63, H1 being 0, the following code marks positions as drawn:

// a feeble attempt at using corresponding squares
if ( isPiece(WHITE,KING, pawn_sq-7) || isPiece(WHITE,KING, pawn_sq-8) || isPiece(WHITE,KING, pawn_sq-9) ) {
   if ( isPiece(BLACK,KING, pawn_sq+15) || isPiece(BLACK,KING, pawn_sq+16) || isPiece(BLACK,KING, pawn_sq+17) ) {
     if (to_move == WHITE && ROW(blackKingLoc) != ROW_8 ) return DRAW;
   }
}

Please note that the code must exclude positions where the defending king is on the last rank. Additionally there are drawn rook pawn cases where the defender prevents the king on the pawn's frontspan from leaving the rook file.

KPK is won

  • Stronger king defends all stop and telestop(s), including the promotion square up to three squares. With defender to move, one has to consider whether the pawn can be captured, since defended stop square does not necessarily imply the pawn is defended as well. Additionally, there is a stalemate exception with the knight pawn.
  • Defending king is (leaves after moving) outside the square of the pawn [2]

if the own king blocks the frontspan, it is still won. However the defending king may further reach the "square of the pawn" due to the extra tempo and one needs to apply some more rules to avoid knowledge holes in that cases.

See also

Selected Publications

1970 ...

1980 ...

1990 ...

Forum Posts

2005 ...

2010 ...

2015 ...

2020 ...

External Links

Key square from Wikipedia

References

  1. Max Bramer (1977) KPK: using effective distance. Open University, Milton Keynes
  2. Set-wise Rule of the Square with Bitboards
  3. kervinck/pfkpk · GitHub
  4. Yet another KPK endgame table generator: pfkpk by Marcel van Kervinck, CCC, September 05, 2015

Up one Level