What's Essential Rook & Pawn Endgame Knowledge?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: What's Essential Rook & Pawn Endgame Knowledge?

Post by hgm »

It enormously helped in Joker to evaluate the relative position of Kings and passers. I added tables attackingKing[king-passer] and defendingKing[king-passer]. They give a bonus for being in front of the pawn, and a penalty for being outside the 'quadrate'. For the attacking King being in front of the Pawn is also good, as long as it is not exactly on the path of the Pawn.
User avatar
cdani
Posts: 2204
Joined: Sat Jan 18, 2014 10:24 am
Location: Andorra

Re: What's Essential Rook & Pawn Endgame Knowledge?

Post by cdani »

Hi!
The LMR stuff is very important in endgames. In fact having good and fast deepening search has won a lot of endgames for Andscacs.

Anyway for the KRPKR I evaluate:

* King control of castling square, pawn less than 6th, rook in 6th, draw.
* King control of castling square, pawn on 6th, draw with rook check from behind.
* King control of castling square, pawn on 6th, king less than 6th, draw.
* King stopping pawn, pawn on 4th or less, scale to draw.
* Special evaluation for pawn on 7th on a/b/c and rook of the same color in front of the pawn (stopping it), and other color king on g7/h7 that sometimes is draw.
* Rook of color of pawn cutting the other king vertically, and pawn on 5th, and king of color of pawn in the same row or in front of the pawn, near victory.
* Rook of color of pawn cutting the other king horizontally, and pawn on columns b or c, and king of color of pawn is next to the pawn, is won.
* Pawn in a side has some less possibilities of win.
* King near the pawn gives some more options of drawing.

Of course all this is mirrored for any color or side of the board.
syzygy
Posts: 5566
Joined: Tue Feb 28, 2012 11:56 pm

Re: What's Essential Rook & Pawn Endgame Knowledge?

Post by syzygy »

BBauer wrote:
And I have a penalty for "side-protecting" a pawn with a rook (rook protects pawn but on the file, not the rank). But these are fairly minor.
This may be plain wrong. Look at Aljechin-Capablanca position which was analyzsed by Awerbach.
BTW, grandmasters do not play the rook endgame correct. Engines are usually worse. Which engine can cope with this position?
Kind regards
Bernhard
[D]5k2/5P1R/8/1p6/8/2K5/1PP3rp/8 w - - 0 1
Funny position:

Code: Select all

 12:31.695  47. 33479373069   +19.650   1.b3 Ke7 2.Kb4 Rxc2 3.Kxb5 Rb2 4.b4 Rc2 5.Ka6 Ra2+ 6.Kb6 Rg2 7.b5 Kf8 8.Ka5 Ra2+ 9.Kb4 Rb2+ 10.Kc5 Rc2+ 11.Kd5 Rd2+ 12.Kc4 Rc2+ 13.Kb3 Rg2 14.Kc3 Ke7 15.Kc4 Rb2
 14:25.980  48  38792929734    +0.000   1.b3 Ke7 2.Kb4 Rxc2 3.Kxb5 Rb2 4.b4 Rc2 5.Ka6 Ra2+ 6.Kb6 Rg2 7.b5 Kf8 8.Ka5 Ra2+ 9.Kb4 Rb2+ 10.Kc5 Rc2+ 11.Kd5 Rd2+ 12.Kc4 Rc2+ 13.Kb3 Rf2 14.Kb4 Rb2+
I'm pretty sure b3 is winning, but these drawing scores are a bit weird. (Also happens at depths 26, 33 and 34.)

Hmmm, still draw scores at depths 49, 50, 51 and 52...
jdart
Posts: 4367
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: What's Essential Rook & Pawn Endgame Knowledge?

Post by jdart »

I am sure there are exceptions, but it is also pretty common in my experience that computers will protect a pawn with a rook on the rank. And this will make the pawn harder to advance, for example when an enemy rook is on the file.

--Jon
PK
Posts: 893
Joined: Mon Jan 15, 2007 11:23 am
Location: Warsza

Re: What's Essential Rook & Pawn Endgame Knowledge?

Post by PK »

IIRC Ed Schroeder proposed a simple rule of thumb: in KRPKR divide score by 2 if the king of the weaker side stands on pawn's path to promotion
Uri Blass
Posts: 10300
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: What's Essential Rook & Pawn Endgame Knowledge?

Post by Uri Blass »

Bloodbane wrote:Hakkapeliitta has zero endgame knowledge (except for detection of draws by insufficient material and king PST centralization bonuses) and it relies completely on Syzygy tablebases for playing a good endgame. I don't see why I should waste my time coding specific endgames into my engine when I can just use tablebases which cover far more cases with less bugs.
Tablebases do not cover more cases and you cannot use them in every node because the engine is going to be too slow.

Examples for cases that tablabases do not cover are the following drawn positions based on my human knowledge

I do not say that it is easy to write code for endgame knowledge but my point is that there is a lot of knowledge in endgames that tablebases do not cover(general knowledge that you need is also to evaluate correctly king relative to passed pawns and centralizing the king without caring about passed pawns is not a good idea because the king can block opponent passed pawn or help to his own passed pawn).

[D]7k/4pp2/8/8/7P/7P/7P/1B4K1 w - - 0 1
[D]6rk/6pp/8/8/8/8/5PPP/5RK1 w - - 0 1
[D]4k3/p1p1p1p1/P1P1P1P1/8/8/8/8/1B2K3 w - - 0 1
[D]8/3ppppk/PQ5p/4q3/8/8/8/4K3 w - - 0 1
[D]R7/P5k1/6pp/8/8/8/r5PP/6K1 w - - 0 1
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: What's Essential Rook & Pawn Endgame Knowledge?

Post by Ferdy »

Steve Maughan wrote: I'm thinking of implementing Lucena and Philidor position knowledge. Are there any other R & P special positions?
This one is draw different from Philidor method. It requires the defending king to go to the shorter side and defending rook to go to the longer side for possible perpetual checks. The rook should be either in a position to capture the pawn and in a position to deliver a perpetual check.
[d]4k3/7R/8/3KPr2/8/8/8/8 b - - 0 1
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: What's Essential Rook & Pawn Endgame Knowledge?

Post by Evert »

Steve Maughan wrote:Maverick seems to be quite weak at endgames when compared to engines of a similar rating. So I'm going to spend some time giving it Rook and Pawn endgame knowledge.
If it knows to advance the pawn and cover the promotion square with the defending king it should have no problem playing the rook ending once it's in one. Of course playing a position well from the root is a different thing from evaluating it correctly at the leaves.
I'm thinking of implementing Lucena and Philidor position knowledge. Are there any other R & P special positions?
Make sure you also score positions that are one ply removed from the Philidor position as drawn, otherwise you will see the score oscilate wildly between won and drawn depending on whether you're in or about o move into the drawn position.

It's probably most important to recognise draw-ish patterns and scale the evaluation for those. Also consider not reducing pawn pushes in the search.
User avatar
Steve Maughan
Posts: 1221
Joined: Wed Mar 08, 2006 8:28 pm
Location: Florida, USA

Re: What's Essential Rook & Pawn Endgame Knowledge?

Post by Steve Maughan »

Thanks everyone - this is exactly what I needed!!

- Steve
http://www.chessprogramming.net - Maverick Chess Engine