KBNK

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

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

Re: KBNK

Post by hgm »

Henk wrote:I played a blitz game a few weeks ago Fairy Max4.8S against Skipper where Skipper was totally lost but the game surprisingly ended in a draw because of the KBNK end game.
KBNK is very rare. But I guess with Fairy-Max 4.8U you won't get away with this anymore! :lol:

But of course it will still walk blindly into KNNK, or even KBK or KNK. Pair-o-Max does recognize those, though, and even discounts positions where your mating potentialis in jeopardy because you only have a single Pawn.
User avatar
hgm
Posts: 27793
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: KBNK

Post by hgm »

Rebel wrote:This is from my programmer page, 2 PST's and king tropism.
...
Indeed, if you know the right corner in advance, you can prepare PST to guide the King to it. Having an attraction between the Kings also helps, I did use that in Usurpator. Fairy-Max does not have that, though. In stead it relies on the PST to decrease quadratically from the center, so that the strong King has to sacrifice less PST points to keep the bare King on the edge than what the latter would gain by stepping away from that edge.

The nice thing of this algorithm is that it also works without any advance knowledge. E.g. when mating with Mammoth (AG) and Phoenix (WA):

Code: Select all

[Event "Computer Chess Game"]
[Site "hgm-xboard"]
[Date "2014.10.12"]
[Round "-"]
[White "Fairy-Max 4.8T"]
[Black "Fairy-Max 4.8T"]
[Result "1-0"]
[TimeControl "40/600"]
[Variant "test"]
[VariantMen "M:GA;X:WA"]
[FEN "8/8/8/8/4k3/8/8/KXM5 w - - 0 1"]
[SetUp "1"]

{--------------
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . k . . .
. . . . . . . .
. . . . . . . .
K X M . . . . .
white to play
--------------}
1. Kb2 {+5.92/19} Kd4 {-5.79/18 8} 2. Kb3 {+6.00/19 10} Kc5 {-6.15/19 8} 3.
Xd3 {+6.07/20 12} Kd6 {-6.10/19 20} 4. Kc4 {+6.06/18 9} Ke5 {-6.07/18 19}
5. Kc5 {+6.06/18 11} Ke4 {-6.07/18 9} 6. Xc3 {+6.09/19 14} Kf5 {-6.09/19 9}
7. Kd5 {+6.11/19 9} Kg5 {-6.11/19 19} 8. Ke5 {+6.10/19 14} Kg4 {-6.10/19 9}
9. Xc4 {+6.11/19 15} Kh4 {-6.11/18 8} 10. Kf5 {+6.14/19 10} Kg3
{-6.12/19 9} 11. Ma3 {+6.15/20 22} Kf3 {-6.19/19 14} 12. Mc5 {+6.34/20 14}
Kg2 {-6.22/19 9} 13. Kf4 {+6.29/20 20} Kf1 {-6.35/20 12} 14. Ke3
{+6.36/20 20} Ke1 {-79.80/21 12} 15. Xc3+ {+6.33/20 10} Kd1 {-6.34/21 13}
16. Kd3 {+6.32/20 8} Kc1 {-6.32/22 18} 17. Xb3 {+6.29/20 18} Kb1
{-6.31/22 9} 18. Ma7 {+6.27/20 13} Kc1 {-6.31/22 8} 19. Md4 {+6.55/21 9}
Kb1 {-6.30/20 9} 20. Mg7 {+6.54/21 12} Ka2 {-6.29/20 10} 21. Kc3
{+6.51/22 10} Ka1 {-6.30/22 10} 22. Xa3 {+6.49/23 17} Kb1 {-6.31/22 10} 23.
Kb3 {+79.71/23 25} Ka1 {-6.32/24 14} 24. Xc5 {+79.72/24 11} Kb1
{-79.67/24 12} 25. Xe3 {+79.73/24 19} Ka1 {-79.74/24 14} 26. Md4+
{+79.74/23 8} Kb1 {-79.76/24 18} 27. Xd3+ {+79.76/23 18} Kc1 {-79.78/24 12}
28. Kc3 {+79.76/23 11} Kd1 {-79.79/24 15} 29. Xe3 {+79.84/23 14} Ke1
{-79.85/24 12} 30. Kd3 {+79.85/23 10} Kf1 {-79.86/24 12} 31. Xf3
{+79.87/23 14} Kg2 {-79.89/24 10} 32. Ke4 {+79.87/23 11} Kf1 {-79.89/20 10}
33. Ke3 {+79.89/23 11} Kg2 {-79.90/23 12} 34. Mf6 {+79.90/23 7} Kh3
{-79.91/23 12} 35. Kf4 {+79.91/23 9} Kg2 {-79.92/24 10} 36. Mh4
{+79.92/24 11} Kh2 {-79.93/24 14} 37. Xf2 {+79.93/26 9} Kh3 {-79.94/28 6}
38. Mf6 {+79.94/28 2.7} Kh2 {-79.95/28 0.5} 39. Kg4 {+79.95/28 0.4} Kg1
{-79.96/28 0.1} 40. Kg3 {+79.96/28 0.1} Kh1 {-79.97/28} 41. Kh3 {+79.97/28}
Kg1 {-79.98/28} 42. Md4+ {+79.98/28} Kh1 {-79.99/28} 43. Xf3# {+79.99/28}
{Xboard adjudication: Checkmate} 1-0
User avatar
hgm
Posts: 27793
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: KBNK

Post by hgm »

I'll celebrate this improvement by equipping the next Fairy-Max with a new variant of my own design, 'Companion Chess'. The idea is that no single piece will have mating potential, so that when it comes to an end-game, you will always need at least a pair of pieces to force checkmate. And many of the pieces will be color bound, so that the corner might matter.

The pieces are (a to h file)

Unicorn: FN (a color alternator)
Phoenix: WA
Mammoth: AG (color bound)
Admiral: BD0mW (basically color-bound, but with a color-changing non-capture)
King
Elephant: FA (color bound)
Knight (color alternator)
Unicorn

The only piece present twice is the Unicorn, a 12-mover, which should be worth nearly a Rook. (But as it attacks only squares of the same color, it has no mating potential.) This is for castling purposes. The Admiral is a Queen that goes along orthogonals in jumps of two. This means it can jump over many pieces, but it also does not attack those squares. Without the color-changing move it should be worth about 700cP (I measured that once), but with the extra manoeuvrability from the W non-captures this probably rises to 800cP.

All the other pieces are 8-movers, worth about a Knight. Only the Mammoth is probably significantly less valuable, as most of its moves are so distant that they are often clipped by the board edge. OTOH it has dangerous forking power in the middle game, as it contains two forward range-3 jumps.

Of all the pairs, only Knight + Mammoth cannot checkmate a bare King. Elephant + Mammoth can do it, but only when on opposite color, as they are both color bound. (But they start on opposite color, and you would not pick them as promotion piece.)
User avatar
hgm
Posts: 27793
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: KBNK

Post by hgm »

Turns out the name 'Companion Chess' was already taken. So the variant played by Fairy-max 4.8U will be called 'Team-Mate Chess'.

It will feature 27 (!) new 3-vs-1 checkmates of an orthodox King with heterogeneous pairs of (mostly novel) pieces, where orthodox Chess only has KBNK. (Only one of the possible material combinations will have no mating potential.) In addition there are 8 homogeneous pairs possible, (but apart from that of the strongest promotion choice, unlikely to occur in real games), where orthodox Chess only has KBBK and KNNK. Of these, only two have no mating potential.

Image
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Not just in the corner

Post by sje »

In some cases, the fastest KBNK mate occurs with the king getting mated on an edge square adjacent to one of the two "right" corner squares.

So, depending on the algorithm in use, six squares need special tropism scores.
User avatar
hgm
Posts: 27793
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Not just in the corner

Post by hgm »

Well, once the engine sees the mate in its search tree, it of course goes goes for the fastest, and static evaluation no longer plays a role.

The stumbling block is usually that (in absence of knowledge of what are the right corners) that you get trapped in a local optimum, in the wrong corner. From there the mate in the other corner is usually outside the horizon, and even if it could force the bare King exactly in that corner (which is usually also outside the horizon), the search would still not see that as an advantage over what it already has achieved.

So the important thing is spoil that local optimum, and the 'board painting' does that nicely. The price is that it takes some 10 extra moves for the program to 'learn' that nothing can be achieved in this corner. But KBNK doesn't take so long that you cannot afford that. In fact you hardly ever encounter a position where it would take the theoretical maximum number of moves in a game, as you usually start with well-centered King and other pieces before the final conversion into it.


The nice thing is that it also helps against other 'no-progress' situations. In Makruk, for instance, Pawns promote to the very weak 'Ferz' (the ancient Queen from Shatranj), which steps only one diagonally. You need 3 of those to force checkmate, or Knight + 2 Ferz. In 4-vs-1 pawnless end-games there is the trap that you would use two of your pieces (e.g. King + Knight) to confine the bare King in a corner (a1 & a2, say), and then start to centralize the other two for maximum PST points, as the mate is still beyond the horizon from there (because it takes too many moves to walk both slow Ferzes to that corner as well, and position everything for executing the mate).

In this situation the 'painting' of a1 & a2 also will make the strong side at some point feel the need to drive the bare King out of that corner, which it cannot do with the two pieces used to confine it. So it is forced to bring in a third piece, unknowingly bringing the mate much closer, so that it will see it.