Page 1 of 2

Single legal move - what to do?

Posted: Wed Aug 12, 2009 5:53 pm
by vladstamate
Hi all,

I am considering two options when faced with the situation when a side has a single legal move that it can do. (Preamble: I only check if there is a single legal move when the king is in check, since my move generator generates semi-legal moves).

Option1:

Instead of carrying on with normal Alpha-Beta search at that point, I switch immediately to QS to get a value for the position and return that. My QS however does not keep going on checks, only captures.

Option2:

Perform an extension. That is keep with normal Alpha Beta but search deeper, probably by 1 or 2 plies. That is in case there is a mate or a tactical win nearby which might make the move that caused this side to have only 1 legal move, quite useful.

What do other people do in this case? I am currently implementing option 1 and see what results I get with that, but I will try option 2, and compare.

Regards,
Vlad.

Re: Single legal move - what to do?

Posted: Wed Aug 12, 2009 6:03 pm
by hgm
Are you talking about the root or just any tree node? Outside the root (1) would be totally fatal. I once had an engine that did this through a bug.

Re: Single legal move - what to do?

Posted: Wed Aug 12, 2009 6:08 pm
by tvrzsky
I can not see any reason for 1. Why jump into QSearch? What I do is basicaly extension by 1 ply.

Re: Single legal move - what to do?

Posted: Wed Aug 12, 2009 6:11 pm
by vladstamate
Actually you do have a very good question. Since the check for "is there only one legal move" is kind-of expensive for me, I thought just to do it at root. Reading you post makes me think that maybe option 1 is better used at root, whereas option 2 could be used at deeper plies.

I would assume the decision on what to do is not influenced by what type of node (not talking about root here, just PV vs non-PV) I am on right ?

And yes, I would imagine, that option 1 would miss a lot of tactical issues if used in non-root nodes.

Regards,
Vlad.

Re: Single legal move - what to do?

Posted: Wed Aug 12, 2009 9:03 pm
by jwes
If there is a single legal move at the root, you could just make the move and start pondering.

Re: Single legal move - what to do?

Posted: Thu Aug 13, 2009 8:27 am
by edwardyu
tvrzsky wrote:I can not see any reason for 1. Why jump into QSearch? What I do is basicaly extension by 1 ply.
Do you mean another 1 ply extension? Since incheck extends 1 ply, single response extends another ply.

Re: Single legal move - what to do?

Posted: Thu Aug 13, 2009 1:54 pm
by tvrzsky
edwardyu wrote:
tvrzsky wrote:I can not see any reason for 1. Why jump into QSearch? What I do is basicaly extension by 1 ply.
Do you mean another 1 ply extension? Since incheck extends 1 ply, single response extends another ply.
Yes, exactly. Single response in check = 2 plies extension.

Re: Single legal move - what to do?

Posted: Thu Aug 13, 2009 3:28 pm
by nanochess
Option 2 is a lot better, as one or two possible movs will not make the search slower. And as said J. Wesley, in root you can start pondering inmediatly. This little trick should be on every chess programmer notebook.

Re: Single legal move - what to do?

Posted: Thu Aug 13, 2009 4:44 pm
by brianr
I added a modified version of this to Tinker a few months ago
(with current testing limits, I cannot really say if it is much better or not, but it does seem to help tactically).

When in check Tinker will also extend if there is only one move,
but only if the current ply is <= (iteration+1)/2.

Without this limit to the "top" of the tree, extending by 2 plys will often result in run away searches.

Re: Single legal move - what to do?

Posted: Thu Aug 13, 2009 5:40 pm
by tvrzsky
brianr wrote:I added a modified version of this to Tinker a few months ago
(with current testing limits, I cannot really say if it is much better or not, but it does seem to help tactically).

When in check Tinker will also extend if there is only one move,
but only if the current ply is <= (iteration+1)/2.

Without this limit to the "top" of the tree, extending by 2 plys will often result in run away searches.
This is why I said "basicaly by 2 plies". Because if it is closer than 4 plies to the horizon then the extension is only 1 ply. And my ordinary check extension is fractional - only 7/8 of ply.