Single legal move - what to do?

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
vladstamate
Posts: 161
Joined: Thu Jan 08, 2009 8:06 pm
Location: San Francisco, USA
Contact:

Single legal move - what to do?

Post by vladstamate » Wed Aug 12, 2009 5:53 pm

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.

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

Re: Single legal move - what to do?

Post by hgm » Wed Aug 12, 2009 6:03 pm

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.

tvrzsky
Posts: 128
Joined: Sat Sep 23, 2006 5:10 pm
Location: Prague

Re: Single legal move - what to do?

Post by tvrzsky » Wed Aug 12, 2009 6:08 pm

I can not see any reason for 1. Why jump into QSearch? What I do is basicaly extension by 1 ply.

vladstamate
Posts: 161
Joined: Thu Jan 08, 2009 8:06 pm
Location: San Francisco, USA
Contact:

Re: Single legal move - what to do?

Post by vladstamate » Wed Aug 12, 2009 6:11 pm

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.

jwes
Posts: 778
Joined: Sat Jul 01, 2006 5:11 am

Re: Single legal move - what to do?

Post by jwes » Wed Aug 12, 2009 9:03 pm

If there is a single legal move at the root, you could just make the move and start pondering.

edwardyu
Posts: 34
Joined: Mon Nov 17, 2008 5:58 am

Re: Single legal move - what to do?

Post by edwardyu » Thu Aug 13, 2009 8:27 am

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.

tvrzsky
Posts: 128
Joined: Sat Sep 23, 2006 5:10 pm
Location: Prague

Re: Single legal move - what to do?

Post by tvrzsky » Thu Aug 13, 2009 1:54 pm

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.

User avatar
nanochess
Posts: 64
Joined: Thu Feb 19, 2009 4:34 pm
Location: Mexico, Mexico
Contact:

Re: Single legal move - what to do?

Post by nanochess » Thu Aug 13, 2009 3:28 pm

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.

brianr
Posts: 356
Joined: Thu Mar 09, 2006 2:01 pm

Re: Single legal move - what to do?

Post by brianr » Thu Aug 13, 2009 4:44 pm

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.

tvrzsky
Posts: 128
Joined: Sat Sep 23, 2006 5:10 pm
Location: Prague

Re: Single legal move - what to do?

Post by tvrzsky » Thu Aug 13, 2009 5:40 pm

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.

Post Reply