Wednesday, January 4, 2012

The Philidor Position in a King Rook and Pawn vs King and Rook endgame

I just worked on fixing the errors in the King Rook and Pawn vs King and Rook endgame evaluation. This endgame is very common and is dominated by two fundamental positions. The Philidor position where the defender can draw and the Lucena position where the attacker can win.

As this KRP vs KR endgame contains more than 50% won positions it is very difficult to find patterns that rule out all the winning positions to be left with the draws. Here instead I try to find positive rules that mark the draw and announce a UNKNOWN if no rules match.  

To find those patterns the chess theory helps. The characteristics of the Philidor position are
  •     the defending king is on the queening square of the pawn or adjacent to it
  •     the opposing pawn has not yet reached its sixth rank
  •     the opposing king is beyond the defender's third rank
  •     the defender's rook is on the third rank


My first unverified version of the patterns was very buggy. I corrected the patterns and added also some rules when the attacker pawn is not very advanced. The engine has now a good understanding of the Philidor position and will try to reach it when losing or try to prevent it when winning.

This is the final performance of the fixed code compared with the first version

                      iCE 0.2          iCE 0.3
Incorrect Draws :      83.061                0
Spotted   Draws :   1.551.216        9.012.914
Missed    Draws : 210.404.306      202.942.608
Spotted   Wins  : 271.313.885      271.396.946        

I now have to have a look at the evaluation of this endgame to spot the Lucena position and give it a higher score so the engine will play / exchange pieces towards it when winning.