The Perils of missing sub-promotion

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

nczempin

The Perils of missing sub-promotion

Post by nczempin »

Funny thing I came across in my Eden silver tests:

[D]8/8/8/8/4Q3/5K1k/6p1/8 b - - 1 56


56. ... g1=N+ {(g2g1N+ Kf3f2 Ng1e2 Kf2xe2 Kh3g3 Ke2e3 Kg3h2) -10.28/6 6 White resigns}
{White resigns} 0-1

Oops!


[Event "Eden 13 silver umax4_0 2"]
[Site "ATZE"]
[Date "2007.09.28"]
[Round "4"]
[White "Umax4_0w"]
[Black "Eden_0.0.13dev03"]
[Result "0-1"]
[Time "normal"]
[Variation "120+6"]
[TimeControl "120+6"]
[SetUp "1"]
[FEN "r1b1kbnr/1pp2ppp/p1p5/8/3NP3/8/PPP2PPP/RNB1K2R b KQkq - 0 1 "]
[Termination "normal"]
[PlyCount "111"]
[WhiteType "program"]
[BlackType "program"]

c5 {(c6c5 Nd4f3 g7g6 00 Bf8h6 Nb1d2 Bh6xd2 Bc1xd2) -0.40/6 10} 2.Ne2 {(d4e2)
-0.12/8 33} Bd7 {(Bc8d7 00 Bd7b5 Nb1c3 Bb5xe2 Nc3xe2) -0.39/6 10} 3.Nbc3 {(b1c3)
+0.15/7 11} O-O-O {(000 00 Kc8b8 Bc1g5 Bf8e7 Bg5xe7 Ng8xe7) -0.38/6 9} 4.O-O {(e1g1)
+0.25/7 8} c4 {(c5c4 Nc3d5 Bd7c6 Nd5c3 Bf8b4 e4e5 Bb4xc3 Ne2xc3) -0.36/6 9} 5.Be3
{(c1e3) +0.03/7 10} Bg4 {(Bd7g4 f2f3 Bg4e6 Ne2f4 Kc8b8 Nf4xe6 f7xe6) -0.54/6 9} 6.f3
{(f2f3) -0.01/7 8} Bd7 {(Bg4d7 Ne2d4 Kc8b8 Be3g5 Bf8e7 Bg5xe7 Ng8xe7) -0.28/6 9} 7.b3
{(b2b3) -0.01/7 12} cxb3 {(c4xb3 a2xb3 Kc8b8 Be3d4 Ng8e7 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/6 6} 55.Ke3
{(d4e3) 0.00/98} g2 {(g3g2 Ke3f3 g2g1Q Qe4e6+ Qg1g4+ Qe6xg4+) -M5/6 6} 56.Kf3 {(e3f3)
0.00/98} g1=N+ {(g2g1N+ Kf3f2 Ng1e2 Kf2xe2 Kh3g3 Ke2e3 Kg3h2) -10.28/6 6 White resigns}
{White resigns} 0-1
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: The Perils of missing sub-promotion

Post by bob »

I am lost. Why did white resign? Obviously the g1=N move is a mate in 6. But if black just promotes to queen it is an instant mate for white.

So why did he resign?
nczempin

Re: The Perils of missing sub-promotion

Post by nczempin »

bob wrote:I am lost. Why did white resign? Obviously the g1=N move is a mate in 6. But if black just promotes to queen it is an instant mate for white.

So why did he resign?
Must be either a bug in Arena, or in umax 4_0.

Perhaps there is some code that when an illegal move is made (which it is only from the pov of a non-sub-promoting engine), it automatically resigns rather than give an error message.
Uri Blass
Posts: 10267
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: The Perils of missing sub-promotion

Post by Uri Blass »

bob wrote:I am lost. Why did white resign? Obviously the g1=N move is a mate in 6. But if black just promotes to queen it is an instant mate for white.

So why did he resign?
The reason is simply the fact that white does not understand underpromotion and the engine assume always promotion to queen.

The author did not want the engine to play illegal moves so he simply
added code to tell it to resign.

He probably thought that it is not counter productive for games because illegal move is a loss but in this example illegal move is a draw because black has no mating material even against the worst play of white
so if we care only about playing strength the interface should not resign for micromax in case that the opponent has only knight against queen(note that knight against pawn bishop knight or rook can win against bad play of the opponent).

Edit:I can add that there is a reason that the author did not tell the engine the underpromotion rule because the target of the author was not to write stronger engine but to write the strongest possible engine that has less than 2048 chars in the code and with these small number of chars it is better to implement things like hash tables(that he did) and not to implement understanding underpromotions.

Uri
nczempin

Re: The Perils of missing sub-promotion

Post by nczempin »

Uri Blass wrote:
bob wrote:I am lost. Why did white resign? Obviously the g1=N move is a mate in 6. But if black just promotes to queen it is an instant mate for white.

So why did he resign?
The reason is simply the fact that white does not understand underpromotion and the engine assume always promotion to queen.

The author did not want the engine to play illegal moves so he simply
added code to tell it to resign.

He probably thought that it is not counter productive for games because illegal move is a loss but in this example illegal move is a draw because black has no mating material even against the worst play of white
so if we care only about playing strength the interface should not resign for micromax in case that the opponent has only knight against queen(note that knight against pawn bishop knight or rook can win against bad play of the opponent).


Edit:I can add that there is a reason that the author did not tell the engine the underpromotion rule because the target of the author was not to write stronger engine but to write the strongest possible engine that has less than 2048 chars in the code and with these small number of chars it is better to implement things like hash tables(that he did) and not to implement understanding underpromotions.

Uri
I think we are all aware of the intentions of the micromax project, and that that is the reason for the missing underpromotions.

Also, your explanation makes it clear to me that not the interface is responsible for the resignation, but the engine. AFAIK Arena takes into account insufficient material.

There are other reasons to postpone sub-promotions, all perfectly valid. I think hgm mentions on his site that he has never come across a situation where he would have needed it. Neither have I with Eden, but I had other goals for my engine and thus have included them. Nice to see that one situation where it payed off! ;-)
nczempin

Re: The Perils of missing sub-promotion

Post by nczempin »

So in fact it is probably not so much an issue of missing sub-promotion, but of how to handle illegal moves. My engine would complain, ignore the move and make its own, thus actually making an illegal move itself and be forfeited.
User avatar
hgm
Posts: 27787
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: The Perils of missing sub-promotion

Post by hgm »

This works exactly as designed! :lol: :lol: :lol:

Perhaps some explanation is in order: uMax 4.x does not know underpromotion. It promotes every pawn that reaches 1st or 8th rank to Q. So if the opponent underpromotes to Knight, it cannot guarantee that its subsequent moves will be legal. For instance, in the given position it would play Qe4-h7# (it thinks). Because it assumes there is a Q on g1, and that it thus is not in check.

Now typically opponents under-promote only in about 1% of the games. (This is about an order of magnitude more than I had imagined before I started testing.) And not always in positions that are won to uMax. On the average it costs about 0.5% in score to forfeit on the illegal move or the unjust illegal-move claim that follows a promotion to N. So fixing it, would bring uMax 3.5 Elo. That means if it would take more than 3 characters to fix it, it would be counter-productive in terms of Elo/char, as the current ratio is slightly over 1. So far I have found no way to implement under-promotion with just 3 characters. So I just take the occasional loss.

Now some testers do not accept programs that can play illegal moves. So in order to let uMax qualify for testing, I had to make sure it wil not ever play any illegal moves. Therefore I let the WB interface (which I do not consider an integral part of uMax, but rather as a device to make user-friendly testing of uMax possible) remember when the opponent under-promotes to Knight. If then, on the next move, uMax does not come with a move that captures the Knight (with uMax still thinks is a Queen), the interface intervenes, and prints a resign message. Because we might be in-check, without knowing it. I figured this would be the major reason why opponents pick a Knight anyway. (Q is upward compatible with B or R, so that will hardly ever lead to illegal moves.)

Now this resign policy is a bit too liberal, and some opponents abuse it! In some positions, like

[d] 6Q1/8/3k4/6p1/8/8/3p3K/8 w

uMax sees no reason to hurry in stopping the promotion, and plays 1. Qxh5, with the idea to play 1. ..., d1=Q; 2. Qd8+, Ke5; 3. Qxd1. The opponent, seeing that he is going to lose the Pawn or what it promotes to no matter what, for some warped reason then chooses to promote to Knight! uMax, completely ignorant of this fact, then comes with Qd8+, but the interface substitutes a resign for this, and the vile trick of the opponent pays off! :twisted: So I really should have the interface test if uMax does wander in check from that Knight, and not resign until it does (or if the opponent moves that Knight, which uMax would not accept).

Note that uMax 1.6 actually does accept under-promotions as input (at the expense of 32 characters), as I wanted it to play fully legal FIDE Chess, to avoid discussions if it really would qualify as the World's smallest Chess program (source-code wise). 8-)
Last edited by hgm on Fri Sep 28, 2007 9:34 pm, edited 1 time in total.
User avatar
hgm
Posts: 27787
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: The Perils of missing sub-promotion

Post by hgm »

Uri Blass wrote:He probably thought that it is not counter productive for games because illegal move is a loss but in this example illegal move is a draw because black has no mating material even against the worst play of white
We had a discussion about this on the Chess War chat a month or so ago. The engine Belofte resigned there in the Promo division, when the opponent had a bare King. We wondered if resigning in that position is legal or not. I think in the end Olivier corrected the score to draw.
MartinBryant

Re: The Perils of missing sub-promotion

Post by MartinBryant »

Unfortunately these non-underpromoting engines sometimes get away with murder!!!

Tao is a particular culprit and I (and several others) simply won't use it because of it.

Ages ago Colossus (playing black) had the following position against Tao 5.6 using the Fritz GUI.

[D]8/7p/1p4p1/P7/7P/1K6/2pq2k1/8 b - - 0 64

Colossus played c1=N+ which is mate in 3.
Now Tao doesn't bother with underpromotions even if the opponent plays them, just assumes all promotions are to queens, so in reply it calmly played the illegal axb
Now unfortunately the Fritz GUI (presumably because it expects only legal moves from engines) allowed it!!!
It then passed the illegal move to Colossus which had a thrombosis, crashed and lost on time!!!! GRRRRRRRRR!!!!!! :evil:

GUI WRITERS PLEASE NOTE! CHECK MOVES FROM ENGINES FOR LEGALITY!!
nczempin

Re: The Perils of missing sub-promotion

Post by nczempin »

hgm wrote:
Uri Blass wrote:He probably thought that it is not counter productive for games because illegal move is a loss but in this example illegal move is a draw because black has no mating material even against the worst play of white
We had a discussion about this on the Chess War chat a month or so ago. The engine Belofte resigned there in the Promo division, when the opponent had a bare King. We wondered if resigning in that position is legal or not. I think in the end Olivier corrected the score to draw.
Does it apply here? I will correct it...

umax had a string of 1 draw and then 6 losses at the start of the second round of the the silver gauntlet; I thought something had crashed, like perhaps I had removed the exe by mistake or something :-)

The other Eden wins were legitimate, I'm happy to say! The draw was another three-moves draw in winning position from umax. Not sure if the 3moves is in 4.8, or how many chars it would cost to add it, but I am sure it is costing you quite a few half-points. That, plus pushing those passers and keeping the king from his frequent excursions, will probably be the most significant improvements I see on the eval-side (plus the centralization we talked about).

I think you should update your goal to 2048 characters, it is a much "rounder" figure than 2000 :-) (My roundest birthday was 32, rounder than 30 I thought; at 16 I wasn't thinking in binary yet---something I seem to regress to---, and 64 seems such a long way away----Bob, you there yet?).