KQKP and the like

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

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

KQKP and the like

Post by hgm »

A Pawn advanced to 7th rank is quite strong when supported by its King, and can often draw even against a Queen. We probably all know the rules for this (Rook or Bishop Pawn etc.), or programmed those in our engines. I am now converting KingSlayer to play "chess with different armies", which features many different kinds of fairy pieces, amongst which super-pieces that might or might not be able to beat a supported 7th-rank Pawn. So it would be nice to have a more generic method to let the engine recognize it stumbled into a draw (long) before 50 moves expire, a method which does not require detailed knowledge of the end-game.

If it is possible to tactically gain the Pawn without King help, it is no problem, as the search will quickly find it, after which any special bonus or multiplier for the supported 7th-ranker (which would shift the score close to a draw) will have disappeared. When the piece is too weak to stop promotion it is also easy, as it will then never take very long to promote (after which the draw is a fact). The problem occurs in positions that can only be won with King help, as the King is slow and can be far away, while moving it will not be possible most of the time because of the promotion threat. In KQKP you have to keep checking until you can force the King to step in front of its Pawn, before your own King can approach one step. After which the checking circus starts all over. This usually pushes the position where you finally gain the Pawn with King help far beyond the horizon. With as a result that the engine will keep evaluating the won game as drawish.

I was wondering if the following would help: keep a counter similar to the 50-move counter, except that you reset it for every move of the strong side's King. And then make the evaluation dependent on the value of that counter, in a rather aggressive way. Like evaluating the position as draw when the King has not moved for, say, 5 turns (10 ply). Then a branch that manages to frequently move the King without allowing promotion would escape the 'drawish' verdict, counting on the idea that when you can move your King often enough, it will eventually be able to aproach enough to eliminate the supported passer. Has anyone tried such a thing?

A alterative would of course be to build the 4-men EGT on the fly. Or perhaps a 3-men EGT for Q-KP (i.e. without white King and a royal Queen instead), where a position with the King blocking its Pawn (and white to move) would be considered the win (and an 8th-rank Pawn with black to move a draw). If that blocked position with black to move would be a loss, we will be able to repetitively drive the King in front of its Pawn, making it likely the end-game is won.
User avatar
stegemma
Posts: 859
Joined: Mon Aug 10, 2009 10:05 pm
Location: Italy
Full name: Stefano Gemma

Re: KQKP and the like

Post by stegemma »

You can also add a simple parameter to evaluation: the distance of the (winning) King to the pawn. More near is the King more value you give to the position. This value must be a little less than pawn score, so the King will move step by step to the pawn and the search will avoid promotion. The only way to move safely the King is to push the enemy King in front of the pawn but this can be done in a few moves, always in the horizon of the search.
Author of Drago, Raffaela, Freccia, Satana, Sabrina.
http://www.linformatica.com
User avatar
hgm
Posts: 27788
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: KQKP and the like

Post by hgm »

Yes, that would help to find the win if the position is won. And such a term would be normally in the evaluation: Kings tend to be attracted to passers. But what I worry about is not that it cannot convert the win, but that it cannot recognize the draw. If it is a c- or an f-Pawn it would see that it can drive the King in front of the Pawn once, but every time after that the King takes shelter on a8/h8 instead, and no further progress can be made. But it doesn't mind that, as even without any progress the score happily stays somewere between +7 and +8. It won't search the 100 ply needed to reach the 50-move axe, and with the Queen roaming the board while checking, it can avoid repetitions for a long, long time as well.

This is why I would like to have a quicker criterion for draw recognition. Progress in this end-game comes from moving the King, rather than from moving a Pawn. Just finding new ways to continue checking with the Queen without repeating leads nowhere; if anything would be achievable by that it would have seen it pretty early. So it would make sense to have a 'no progress' counter that resets on King moves, rather than Pawn moves. And these King moves had better come much faster than once every 50 moves, or the King would not make it in time.