IID and move sorting

Discussion of chess software programming and technical issues.

Moderators: hgm, Dann Corbit, Harvey Williamson

Daniel Shawul
Posts: 4185
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

IID and move sorting

Post by Daniel Shawul »

Now that I have a move generator that can revisit moves (does a second pass) which was required for ABDADA, I got two immediate benefits for the sequential searcher.

a) Moves does not have to be generated again, so I will just set the move generation status to GEN_RESET. So this saves move generation calls at internal nodes and also have the nodes counts as scores. The benefit from saving move generation might not be that important but move sorting as in (b) may help specially with LMR. Right now if the IID failed high, I do not do it since I will only have a partial move list. Instead I pick the two moves with the highest nodes count and put them in killers list.

b) The second benefit (hopefully important) is now I can sort the moves based on nodes count like it is done for root sorting. In the past there were attempts to use that kind of sorting using smaller hash tables on PV nodes other than the root. I guess this is a good alternative to that idea specially if you do IID in many internal nodes. The IID will bring up a good first move in any case, but sorting the other moves maybe of some help anyway.

I do internal iterative deepening not only on PV nodes but on CUT nodes as well so the chances of doing IID are higher. I haven't measured how much I get from this but it is working fine in Nebiyu now. Before I did this full move sorting at internal nodes, I tried to take advantage of the idea via killers. That worked but I did not bother to measure the elo improvement I got from it if any.

Daniel

Psuedo code after IID is finished:

Code: Select all

case IID_SEARCH:
			sb->pstack->hash_move  = sb->pstack->best_move;
			sb->pstack->hash_score = sb->pstack->best_score;
			if(sb->pstack->flag == EXACT || sb->pstack->flag == LOWER)
				sb->pstack->hash_flags = HASH_GOOD;
			sb->pstack->hash_depth = sb->pstack->depth;
			sb->pstack->search_state = SINGULAR_SEARCH;
			/*reset move generation*/
			if(sb->pstack->flag == LOWER) {
				sb->pstack->gen_status = GEN_START;
				/*put two moves with highest nodes count in killers*/
				sb->pstack->sort(0,sb->pstack->count);
				move = sb->pstack->move_st[0];
				if(move == sb->pstack->best_move) {
					sb->pstack->sort(1,sb->pstack->count);
					sb->pstack->killer[0] = sb->pstack->move_st[1];
					sb->pstack->sort(2,sb->pstack->count);
					sb->pstack->killer[1] = sb->pstack->move_st[2];
				} else {
					sb->pstack->killer[0] = move;
					sb->pstack->sort(1,sb->pstack->count);
					sb->pstack->killer[1] = sb->pstack->move_st[1];
				}
			} else {
				sb->pstack->gen_status = GEN_RESET_SORT;
				/*put best move first*/
				for&#40;int i = 0;i < sb->pstack->count;i++) &#123;
					if&#40;sb->pstack->hash_move == sb->pstack->move_st&#91;i&#93;)
						sb->pstack->score_st&#91;i&#93; = MAX_NUMBER;
				&#125;
			&#125;
			break;
Daniel Shawul
Posts: 4185
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Re: IID and move sorting

Post by Daniel Shawul »

For those who speak only the elo language

Code: Select all

Num. Name              games   score 
   0 Scorpio_18&#58;38&#58;42   4000    2097 
   1 Scorpio_2.7.5      4000    1903 
Rank Name               Elo    +    - games score oppo. draws 
   1 Scorpio_18&#58;38&#58;42     7    5    5  4000   52%    -7   50% 
   2 Scorpio_2.7.5       -7    5    5  4000   48%     7   50% 
It is a 52% win against previous version.