This is a temporary, read-only recovery of the chessprogrammingwiki while a longer-term plan is worked out. Editing is not possible right now, but will be again soon.
Chess Programming Wiki All pages Other namespaces

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.

Contents
  1. Bitbase
  2. Perfect Heuristics
  3. Imperfect Heuristics
    1. KPK is drawn
    2. KPK is won
  4. See also
  5. Selected Publications
    1. 1970 ...
    2. 1980 ...
    3. 1990 ...
  6. Forum Posts
    1. 2005 ...
    2. 2010 ...
    3. 2015 ...
    4. 2020 ...
  7. External Links
  8. References

Bitbase

Since only 3 pieces are involved, it can be handled easily by a 12 KByte per side, pre-calculated bit table that returns the status of this ending from any of the 64*64*4*6 = 98304 distinct configurations for the pawn on one wing. It is always a win or draw for the side with the pawn. Boolean win or not information requires some distance heuristics though to ensure progress.

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

// 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

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 ...

Key square from Wikipedia

References

Up one Level


  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↩︎

What links here

Contributors: GerdIsenberg.