UCI: seldepth

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
Onno Garms
Posts: 224
Joined: Mon Mar 12, 2007 7:31 pm
Location: Bonn, Germany

UCI: seldepth

Post by Onno Garms »

What is seldepth in the UCI protocol?

The UCI specification does not explain that:
* seldepth <x>
selective search depth in plies,
if the engine sends seldepth there must also be a "depth" present in the same string.
For me, seldepth was always the largest depth that was ever searched on that "go" command. Consequently, seldepth is always greater or equal depth. I do not count qsearch.

For Stockfish, seldepth is the length of the PV. For some reason, it can happen that the PV is shorter than depth, and consequently seldepth can be smaller than depth.

I find my understanding more plausible, but the following example from the UCI specification might indicate that I am wrong:
info depth 1 seldepth 0
However this might also be the output when the search is started at depth 1, but not a single move has been searched.
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: UCI: seldepth

Post by mcostalba »

Onno Garms wrote: I find my understanding more plausible
yes, I agree with you, OTH it is not so easy and cheap to implement your definition, so the compromise is what is done currently in SF, the alternative would be no seldepth at all (as it was till last version).
User avatar
rvida
Posts: 481
Joined: Thu Apr 16, 2009 12:00 pm
Location: Slovakia, EU

Re: UCI: seldepth

Post by rvida »

Onno Garms wrote: For me, seldepth was always the largest depth that was ever searched on that "go" command. Consequently, seldepth is always greater or equal depth. I do not count qsearch.
I think your interpretation is the most sensible. Critter counts "seldepth" exactly same way.
User avatar
hgm
Posts: 27796
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: UCI: seldepth

Post by hgm »

Why would you not count Qsearch?
ernest
Posts: 2041
Joined: Wed Mar 08, 2006 8:30 pm

Re: UCI: seldepth

Post by ernest »

mcostalba wrote: OTH it is not so easy
OTH ??? meaning ??? :o

http://www.acronymfinder.com/OTH.html seems helpless...

maybe you mean OTOH ? :)
User avatar
Onno Garms
Posts: 224
Joined: Mon Mar 12, 2007 7:31 pm
Location: Bonn, Germany

Re: UCI: seldepth

Post by Onno Garms »

hgm wrote:Why would you not count Qsearch?
No particular reason.
User avatar
Onno Garms
Posts: 224
Joined: Mon Mar 12, 2007 7:31 pm
Location: Bonn, Germany

Re: UCI: seldepth

Post by Onno Garms »

mcostalba wrote: it is not so easy and cheap to implement your definition, .

It is easy. Have a variable "seldepth" in the search module, initialize to zero. At every node, check height against seldepth, update and send if necessary. With multiple threads, things become a little more compicated of course. (I have one seldepth per thread, each thread sends to the Callback module if updated, and the Callback module joins them in a critical section.

The Callback module is cheap because the number of calls to it are at most the number of threads times maximum seldepth, which amounts to less then 500. Checking the local variable "seldepth" in search module costs some cycles, but I don't think that that is important.
User avatar
hgm
Posts: 27796
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: UCI: seldepth

Post by hgm »

You could even do it for free. If you have some array indexed by ply (like killers...), which is only used in full-width search, initialize it by something invalid, and after the search, check how far it was overwritten.
User avatar
Onno Garms
Posts: 224
Joined: Mon Mar 12, 2007 7:31 pm
Location: Bonn, Germany

Re: UCI: seldepth

Post by Onno Garms »

hgm wrote:You could even do it for free. If you have some array indexed by ply (like killers...), which is only used in full-width search, initialize it by something invalid, and after the search, check how far it was overwritten.
In deed, you are right. Onno has an array of nodes (a stack replacement in iterative search), so I could check that. However I doubt that the tiny expected speedup is worth the change.
User avatar
michiguel
Posts: 6401
Joined: Thu Mar 09, 2006 8:30 pm
Location: Chicago, Illinois, USA

Re: UCI: seldepth

Post by michiguel »

Onno Garms wrote:
hgm wrote:You could even do it for free. If you have some array indexed by ply (like killers...), which is only used in full-width search, initialize it by something invalid, and after the search, check how far it was overwritten.
In deed, you are right. Onno has an array of nodes (a stack replacement in iterative search), so I could check that. However I doubt that the tiny expected speedup is worth the change.
To have something more compact so each thread can have its own variable and if maximum ply is 63, there could be:

Code: Select all

uint64_t pliesreached;
initialized at the beginning of search with

Code: Select all

pliesreached = 0;
and at each node you can do

Code: Select all

pliesreached  |=  U64&#40;1&#41; << ply; 
And then the number of bits are counted.
For SMP search, each thread could have its own variable to avoid cache problems an the variables are OR'd.
If the if maximum ply i> 63

Code: Select all

uint64_t pliesreached&#91;4&#93;;
and at each node

Code: Select all

pliesreached&#91;ply>>6&#93;  |=  U64&#40;1&#41; << &#40;ply&63&#41;;
Then count the bits of the array pliesreached.

Miguel