Mating potential

# Heuristics for accounting for mating potential

## Introduction

It is quite annoying to see a Chess program that is clearly winning trade its last Pawn, to be left with a material combination that, although much stronger than the opponent, cannot deliver checkmate. But computers are stupid, and when they are told that a Knight is worth 3 Pawns, they think they have a very good deal when the can trade their remaining two Pawns for the Knight in K+N+2P vs K+N. While every Chess player of course knows that K+N vs K is a reglementary draw without even so much as a help mate. Even K+2N vs K would not be able to force a win, but the engine counts it happily as +6, and would prefer it over K+R vs K when given the choice.

This kind of stupidity can affect the value of pieces that are susceptible to such mishaps. Not only does the engine blunder easy wins away, but it can also miss clever opportunities to secure a draw in a losing position, by not sacrificing material to destroy mating potential before it is too late, e.g. N for P in K+N vs K+N+P, or R for B in K+B+2N vs K+R.

## Pair-o-Max

Pair-o-Max is a version of Fairy-Max that was enhanced to have some more awareness of such problems. As this required keeping track of how many pieces of each type are still around, it could also easily award an extra score bonus for having a pair of pieces of a certain type, such as the Bishop pair. (Hence the name Pair-o-Max.) The standard version valued Bishops higher than Knights to prevent it from squandering away its B-pair all too easily. This can have the undesired effect that it clings to its Bishop too much when this is no longer needed (making it too reluctant to trade a lone Bishop for a Knight in positions where the latter threatens to do damage). But what is worse, is that it still gives up its advantage if it has destroyed the B-pair of the opponent, but still has its own. No matter how much it values the Bishop, a B vs B trade is always an equal trade, so in B+B vs B+N it sees nothing wrong with trading B for B, unwittingly giving up half a Pawn (lowering its score expectation by a not insignificant 8%).

## A heuristic to account for mating potential

To prevent most of this misery, Pair-o-Max uses a heuristic to discount the score of 'drawish endings'. One quite universally valid rule is that without Pawns you need about twice as much advantage to win. So when the leading side has no Pawns, Pair-o-Max will divide the score by 2. This had some undesirable effects for the K+R vs K ending, and indeed there is no reason to discount endings that are simple theoretical wins even without Pawns. Therefore an exception is made for cases when the opponent has a bare King, or a King + Pawns, as it is usually also trivial to gobble up the Pawns in such a case.

This does not solve the problem of K + N or K + 2N vs bare King yet, however. Especially the latter, with a nominal advantage of 6-6.5 Pawns, needs a huge discount to express the fact that it offers less winning prospects than K + P. Therefore (pawnless) piece combinations without mating potential on the leading side will cause the score to be divided by 8. The general heuristic used for this is that an advantage of less than 3.5 Pawn in terms of piece material (covering the 'minors' B and N of orthodox Chess) will not be enough to provide a forced win. This rule is applied in 1:0, 1:1, 2:0 and 2:1 situations (attacking:defending pieces, ignoring King and Pawns). So it covers K+N and K+B vs K, but also K+R vs K+N, K+R+N vs K+R, K+Q+B vs K+Q, K+B+N vs K+B etc. This might miss some more complex cases, like K+R+B vs K+N+N, but in 2:2 situations you will in gneral not be that much ahead, and (like the 1:1 situations) they are still subject to the division-by-2 discount for being pawnless.

The "minor ahead is not enough" rule needs some refinement, however. Some unorthodox pieces are special by having mating potential against bare King. The Woody Rook (WD) and Commoner (WF) are the best known examples of this. If you have such a piece, being a minor ahead can be enough to secure a win; you only have to trade the other material, to be left in a won 1:0 situation. So the factor 8 is not applied if you have, for instance, K+WD+N vs N. To this end light pieces can be marked as having mating potential in Pair-o-Max game-definition file, by appending a 0,3 at the end of their move-descriptor list. (Since 0 is an invalid step, not displacing the piece at all, this can be distinguished from a normal step,moveRights descriptor.)

Apart from exceptions, the general rule also needs extensions. In particular to recognize cases like K+2N vs K, where even two minors cannot deliver mate. The chances that this happens with a pair of pieces of the same type is far larger than that it would happen when they are of different type, as in the latter case you have much more options for manoeuvring, depending on which piece you use to trap the King, and which to check it. Pair-o-Max allows at least the recognition of this "non-mating pair of equal pieces", by marking the piece type with a 0,-4 suffix at the end of its move-descriptor list. This makes them suffer the factor-8 discount in Pawnless end-games, enough to suppress the advantage to below one Pawn, and thus prefer any other option where it still has an advantage. Note that pairs of Ferzes or Wazirs, which also do not provide mating potential, need not be marked as such, as even the value of such a pair does not exced the 350cP limit.

Another extension is required for 'heavy' color-bound pieces. A single color-bound piece obviously has no mating potential, no matter how valuable it is. And color-bound pieces can be pretty valuable. The BD compound is worth about a Rook, and the BDD ('Adjutant' or leaky Queen) even ~7 Pawns. Color-bound pieces also have a pair bonus, and Pair-o-Max automatically recognizes color-binding on simple pieces (i.e. if they are not hoppers or alternators), and awards them a pair bonus of 1/8 of their base value. (This can be overruled by hand, by adding a 0,BONUS element at the end of their move-descriptor list, where BONUS is a bonus > 3 centi-Pawn.) The presence of such a bonus is used by the mating-potential heuristic to recognize it as a color-bound piece, and in 1:1 or 1:0 situations would also make it apply the factor 8. Enough to reduce even an advantage of an Adjutant to below that of a Pawn.

Finally there is an exceptional case that I refer to as "tough defender". The only example of this I am aware of is the Commoner (WF). This is special, because it cannot be approached in any way by a King. Due to this property it can be an excellent defender agains King + super-piece. E.g. K+Q vs K+WF is a draw, where K+Q vs K+R is a general win. All you have to do is keep the Commoner protected with your King, and there is no way the Queen can harm it on her own. In the mean time you can use it as a shield against checks, and to keep the enemy King at bay (or even chase it back with checks). Defenders that draw in 1:1 situations even when behind far more than 350 cP in piece material can be marked with 0,-1 at the end of their move-descriptor list. This also is taken to imply mating potential against bare King.

## Mating potential in jeopardy

When you still have Pawns it is never a done deal, but you can nevertheless be in a pretty bad spot if the opponent can afford to sacrifice his least-valuable piece for your last one, to leave you without mating potential. Such a threat of sacrifice often can be used to hold off advance of the Pawn indefinitely. This situation is recognized in 1:1, 1:2, 2:1 and 2:2 situations (discarding King and Pawns), which after sacrifice become 1:0, 1:1, 2:0 and 2:1 situations that match the criteria described in the previous section. These situations are therefore strongly discouraged for the leading side, by dividing the score by 4. Not as much as the factor 8 they would suffer when the last pawn is already sacrificed away (because who knows, maybe they can shield it from that), but stil pretty bad. In any case, enough to make Pair-o-Max cling to its second-last Pawn like its life depended on it. Even winning a minor for that Pawn would no longer seem an attractive deal, e.g. in K+2N+2P vs K+B+N+P (+1) it would try to avoid conversion to K+2N+P vs K+N+P (0.75 after discount), and prefer conversion to K+N+2P vs K+B+P (still +1) over it.