Komodo misses mate in 1...

Discussion of anything and everything relating to chess playing software and machines.

Moderator: Ras

Sean Evans
Posts: 1777
Joined: Thu Jun 05, 2008 10:58 pm
Location: Canada

Re: Komodo misses mate in 1...

Post by Sean Evans »

Don wrote:I think Rybka does the same - I have heard people complain about this on the Rybka forum.
Hi Don,

Long time no speak! Actually, there was a recent Rybka game posted with a pawn changing into a Bishop, you can read it here:

http://talkchess.com/forum/viewtopic.ph ... highlight=
User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 4:27 pm

Re: Komodo misses mate in 1...

Post by Don »

Sean Evans wrote:
Don wrote:I think Rybka does the same - I have heard people complain about this on the Rybka forum.
Hi Don,

Long time no speak! Actually, there was a recent Rybka game posted with a pawn changing into a Bishop, you can read it here:

http://talkchess.com/forum/viewtopic.ph ... highlight=
Nice to hear from you again. Interesting stuff about the bishop.
Edmund
Posts: 670
Joined: Mon Dec 03, 2007 3:01 pm
Location: Barcelona, Spain

Re: Komodo misses mate in 1...

Post by Edmund »

Don wrote:[...]

In my program the program wants to do all under-promotions and I have merely commented out the part of the code that tries to generate these moves so I can bring it back at will.

If I want to cover all promotions, I think the most common theme, other than knight check is promoting to some piece that does not stalemate the opponent. There is also the theme of under-promoting to force a draw!

1r5K/6PP/8/8/8/1k4q1/6P1/8 w - -

promoting to a queen loses to K anywhere, QxR and black wins but if you promote to a bishop it is pinned and you stalemate. So even this could be covered by including all check promotions, but that is probably more than I want because there are a lot of silly check underpromotions that could have been a queen promotion.

So one way to cover this stuff in a practical way is probably to include all under-promotions but reduce the depth by several ply so that the branching factor of the program is not seriously affected.
That is an interesting position, thanks for posting it. Sofar I thought Bishop/Rook promotion only makes sense if the Queenpromotion returns a draw-score, but you proved me wrong.

So are there any other special cases? Does this only concern Bishop underpromotions or also the Rook ones?
If not than you can save your reduced depth search and just use the algorithm:
if Queenprom returns draw {
try rook, bishop underpromotion
}
else if Queenprom returns losing {
if Bishoppromotion is checking, stm can't move, ... {
try bishop underpromotion
}
}
alpha123
Posts: 660
Joined: Sat Dec 05, 2009 5:13 am
Location: Colorado, USA

Re: Komodo misses mate in 1...

Post by alpha123 »

Edmund wrote: If not than you can save your reduced depth search and just use the algorithm:
if Queenprom returns draw {
try rook, bishop underpromotion
}
else if Queenprom returns losing {
if Bishoppromotion is checking, stm can't move, ... {
try bishop underpromotion
}
}
I suggested something like that, only probe the hash first to see if we thought we were winning earlier. Also search all of them at the root to save some time.

Peter
Edmund
Posts: 670
Joined: Mon Dec 03, 2007 3:01 pm
Location: Barcelona, Spain

Re: Komodo misses mate in 1...

Post by Edmund »

alpha123 wrote:
Edmund wrote: ...
I suggested something like that, only probe the hash first to see if we thought we were winning earlier. Also search all of them at the root to save some time.

Peter
I don't quite get your reference to the hash probe;
First of all, a transposition table hit is not very likely and even if there is an old entry, it will not hold any additional information, as the pruning criteria would have been the same the last time we visited the node and these decissions are depth independent.
Secondly you will search the Q-promotion anyway so you can get the relevant information from there to decide whether to try any subpromotions.
alpha123
Posts: 660
Joined: Sat Dec 05, 2009 5:13 am
Location: Colorado, USA

Re: Komodo misses mate in 1...

Post by alpha123 »

Edmund wrote:
alpha123 wrote:
Edmund wrote: ...
I suggested something like that, only probe the hash first to see if we thought we were winning earlier. Also search all of them at the root to save some time.

Peter
I don't quite get your reference to the hash probe;
First of all, a transposition table hit is not very likely and even if there is an old entry, it will not hold any additional information, as the pruning criteria would have been the same the last time we visited the node and these decissions are depth independent.
Secondly you will search the Q-promotion anyway so you can get the relevant information from there to decide whether to try any subpromotions.
After determining that Q promotion doesn't win, THEN probe the hash _EARLY_ to see if we were "winning" before (e.g. lazy eval returned we were up material). If not, there's really no point in looking at underpromotions, they're too rare, especially in losing positions.

Peter
Edmund
Posts: 670
Joined: Mon Dec 03, 2007 3:01 pm
Location: Barcelona, Spain

Re: Komodo misses mate in 1...

Post by Edmund »

alpha123 wrote:
Edmund wrote:
alpha123 wrote:
Edmund wrote: ...
I suggested something like that, only probe the hash first to see if we thought we were winning earlier. Also search all of them at the root to save some time.

Peter
I don't quite get your reference to the hash probe;
First of all, a transposition table hit is not very likely and even if there is an old entry, it will not hold any additional information, as the pruning criteria would have been the same the last time we visited the node and these decissions are depth independent.
Secondly you will search the Q-promotion anyway so you can get the relevant information from there to decide whether to try any subpromotions.
After determining that Q promotion doesn't win, THEN probe the hash _EARLY_ to see if we were "winning" before (e.g. lazy eval returned we were up material). If not, there's really no point in looking at underpromotions, they're too rare, especially in losing positions.

Peter
The usual procedure is to probe the TT before searching any moves. Thats because the TT often holds a bestmove which is to be searched first.
User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 4:27 pm

Re: Komodo misses mate in 1...

Post by Don »

The next version of Komodo will be able to handle the basic cases - I am testing now for any regressions, but essentially I'm generating knight promotions if they are checks in the main search. We plan to release pretty soon by the way.

I thought about just reactivating knight promotions at the root, but that is clearly not good enough when a king is fighting against a promotion with a major piece and it's important to understand this theme.
metax wrote:Komodo doesn't know underpromotions? Or what's the matter here?


1nnn4/Pnkb4/1bbb4/8/8/8/8/3K4 w - -

Engine: Komodo32 1.0 JA (128 MB)
by Don Dailey

13.01 0:01 -11.59 1.a8Q Na5 2.Qxc6+ Nbxc6 3.Ke2 Nc4
4.Kf3 Bd4 5.Ke4 Ne6 6.Kf3 Ng5+ 7.Ke2 Bg4+
8.Kd3 N8b6 9.Kc2 Nb4+ 10.Kc1 Bf4+
11.Kb1 (1.275.735) 860

13.07 0:01 -11.59 1.a8Q Na5 2.Qxc6+ Nbxc6 3.Ke2 Nc4
4.Kf3 Bd4 5.Ke4 Ne6 6.Kf3 Ng5+ 7.Ke2 Bg4+
8.Kd3 N8b6 9.Kc2 Nb4+ 10.Kc1 Bf4+
11.Kb1 (1.277.326) 852

14.01 0:14 -M10 1.a8Q Na5 2.Qxc6+ Nbxc6 3.Kd2 Nc4+
4.Ke2 Bg4+ 5.Kd3 N6e5+ 6.Kc2 Bf5+
7.Kc3 Ndc6 8.Kb3 Bd4 9.Ka4 Nb4
10.Kb3 Bc2+ (12.460.807) 868

14.07 0:14 -M10 1.a8Q Na5 2.Qxc6+ Nbxc6 3.Kd2 Nc4+
4.Ke2 Bg4+ 5.Kd3 N6e5+ 6.Kc2 Bf5+
7.Kc3 Ndc6 8.Kb3 Bd4 9.Ka4 Nb4
10.Kb3 Bc2+ (12.553.538) 868

best move: a7-a8Q time: 0:14.571 min n/s: 868.084 nodes: 12.553.538


I mean, if you ignore bishop underpromotion, it's still ok. But ignoring knight and rook underpromotions really cripples the engine for analysis because especially knight underpromotions happen frequently in real games...
alpha123
Posts: 660
Joined: Sat Dec 05, 2009 5:13 am
Location: Colorado, USA

Re: Komodo misses mate in 1...

Post by alpha123 »

Edmund wrote:
alpha123 wrote:
Edmund wrote:
alpha123 wrote:
Edmund wrote: ...
I suggested something like that, only probe the hash first to see if we thought we were winning earlier. Also search all of them at the root to save some time.

Peter
I don't quite get your reference to the hash probe;
First of all, a transposition table hit is not very likely and even if there is an old entry, it will not hold any additional information, as the pruning criteria would have been the same the last time we visited the node and these decissions are depth independent.
Secondly you will search the Q-promotion anyway so you can get the relevant information from there to decide whether to try any subpromotions.
After determining that Q promotion doesn't win, THEN probe the hash _EARLY_ to see if we were "winning" before (e.g. lazy eval returned we were up material). If not, there's really no point in looking at underpromotions, they're too rare, especially in losing positions.

Peter
The usual procedure is to probe the TT before searching any moves. Thats because the TT often holds a bestmove which is to be searched first.
Shows how much I know about chess programming, doesn't it.....

Peter
User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 4:27 pm

Re: Komodo misses mate in 1...

Post by Don »

Cool. That's a neat idea.

Yeah, sounds smart. Underpromotions don't happen all that often, so limit it to like 2-4 ply to avoid missing something important but not mess anything up with branching. Actually, I suppose you could generate them, search them only at the root, examine Q promotions, and if they draw probe the hash to see if we were winning earlier, and search underpromotions in N, R, B order. Just an idea. (from a 13 year old who does about no chess programming [yet])

Peter[/quote]

Hey Peter,

When are you going to start your own chess program? I think you should go ahead and try. My first program was horrible and so will yours, but that is ok - nothing prevents you from improving it as you go or scrapping it later for a rewrite.

Start with the most basic thing and go from there. Don't copy some public domain code but figure out the data structure for yourself - copying code is like using a calculator instead of first learning how to add and subtract for yourself.

Do you do any programming? If not, now is a good time to learn. Mabye by the time your are 15 or so you will have a very strong program if you start learning C now!

Don