RootMove sorting in Stockfish

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
Look
Posts: 365
Joined: Thu Jun 05, 2014 2:14 pm
Location: Iran
Full name: Mehdi Amini

RootMove sorting in Stockfish

Post by Look »

Hi,

Since I am not a C++ coder, can you describe what is the sorting method of RootMove in Stockfish 9 ? In other words IMHO how the moves are sorted and fed into AlphaBeta ?
Farewell.
User avatar
Eelco de Groot
Posts: 4565
Joined: Sun Mar 12, 2006 2:40 am
Full name:   

Re: RootMove sorting in Stockfish

Post by Eelco de Groot »

I'm not really the one to ask but, as far as I know, no special Root move sorting in Stockfish. This is by design because, apparently, it works better not changing the order in which moves are searched. Only the best move found so far is at the top, immediately below that earlier best moves found by search (I think, but admittedly I have not checked). The rest of the order, moves which were never best move, is the order in which the moves are placed by movepick.cpp on characteristics of the moves alone, so not sorted by eval or search in any way, (but SEE plays a role). This is usually referenced as 'move sorting' in theory, so if that is what you were asking I must refer to movepick.cpp
Debugging is twice as hard as writing the code in the first
place. Therefore, if you write the code as cleverly as possible, you
are, by definition, not smart enough to debug it.
-- Brian W. Kernighan
User avatar
Look
Posts: 365
Joined: Thu Jun 05, 2014 2:14 pm
Location: Iran
Full name: Mehdi Amini

Re: RootMove sorting in Stockfish

Post by Look »

I may ask about a mission here:

Modify Stockfish 9 such that given a "command FEN", it would output the FEN and the move sort of the root moves. That is, how moves are sorted before being given to Alpha-Beta.
Farewell.
syzygy
Posts: 5566
Joined: Tue Feb 28, 2012 11:56 pm

Re: RootMove sorting in Stockfish

Post by syzygy »

Look wrote: Sun May 13, 2018 12:57 pm I may ask about a mission here:

Modify Stockfish 9 such that given a "command FEN", it would output the FEN and the move sort of the root moves. That is, how moves are sorted before being given to Alpha-Beta.
Your signature suggests you at least know some basic C. You should be able to accomplish your mission...

You might learn then that, as has already been explained by Eelco, the root moves are sorted as the search iterates through its iterations. So there is no "the move sort of the root moves".
syzygy
Posts: 5566
Joined: Tue Feb 28, 2012 11:56 pm

Re: RootMove sorting in Stockfish

Post by syzygy »

And if you know C but somehow cannot understand C++, just have a look at how Cfish sorts the root moves (identically to Stockfish):
https://github.com/syzygy1/Cfish