few search related questions ?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

MahmoudUthman
Posts: 234
Joined: Sat Jan 17, 2015 11:54 pm

few search related questions ?

Post by MahmoudUthman »

This is my root ID function :

Code: Select all

Move IterativeDeepning(size_t maxdepth)
{
	//GenerateMoves
	for &#40;size_t d = 1; &#40;d <= maxdepth&#41; & !TimeManager&#58;&#58;Stop&#40;) ; d++)
	&#123;
		//Score&sortMoves
		for &#40;AllMoves&#41;
		&#123;
			MakeMove&#40;)
			Score = -AlphaBeta&#40;-beta, -alpha, d , true&#41;;//should i start with depth=1 , or depth=0 to descnd into qsearch first for a basic ordering ?!
			UnMakeMove&#40;);
			//.
			//.
		&#125;
		//output info
	&#125;
	return BestMove;
&#125;
Fail-hard : Alpha Beta :

Code: Select all

alphabeta
&#123;
//Check for draw by insufficient material
//Check for draw by threefold repetition
//if depth == 0 qsearch
//check for ttCuts
//Do null move pruning
//generate,score,sort and search moves
&#58;if&#40;score>=beta&#41; TTStore&#40;Available&#91;i&#93;, depthleft, BoundType&#58;&#58;Lower, Score&#41;;
//Check for Checkmate and stalemate &#58;if found &#58; TTStore&#40;Move&#40;), depthleft, BoundType&#58;&#58;Exact, Score&#41;;
//TTStore&#40;mBest, depthleft,BoundType&#58;&#58;Upper if no move raised alpha otherwise Exact, alpha&#41;; 
&#125;
1-AS far as I understand checking for ttcuts should be done before null move pruning , but when I switch the two the strength of the engine doesn't change , does this mean that the tt implementation is suboptimal or is this normal ?
2-should I check for 3-fold repetition at the root ?
3-should I be using the tt in anyway in the root-ID search ? and how ?
4-I found an old post by prof Hyatt in which he mentioned that "There is really nothing useful to be
gained by probing at ply=1"
, does this mean that the first probe I do when alphabeta is called from root-ID function is completely useless ?
5-I intend to switch to Fail-Soft alphabeta , is there any special consideration that I should be aware of first ? I found the following in the wiki : "but might also require some care regarding to search instability issues in conjunction with transposition tables and various pruning-, reduction- and extension techniques." ?
6-what is the best move ordering to use at the root , and should the first round of ID be ordered differently ?
Ras
Posts: 2488
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: few search related questions ?

Post by Ras »

MahmoudUthman wrote:2-should I check for 3-fold repetition at the root ?
Doesn't cost much, I'm doing that already for the root move sorting.
does this mean that the first probe I do when alphabeta is called from root-ID function is completely useless ?
IMO yes. I'm starting the ID at search depth 3 (plus QS).
what is the best move ordering to use at the root , and should the first round of ID be ordered differently ?
I first generate the full move list. This includes sorting them by MVV-LVA and static piece square tables.

Then there is a look at the old PV. If the opponent's move was predicted by the PV, then I look through the root move list for the matching PV answer move, put it to the top of the list and shift the other moves down by 1 place.

I have a "play and sort moves" routine. This one takes the root move list, makes all moves and attaches an alpha beta minimax search of remaining depth=2 to each of them. The resulting score for each move is stored, and then the root move list is sorted as per these values.

Since draw by repetition is included in this pre-search, a repetition root move will automatically have a draw result. If better moves are available, such a repetition draw move will get placed down.

Then (in case of a PV hit, see above), I put the PV answer move to the top again, just in case it got sorted away in that shallow sorting pre-search.

The topmost move in the re-sorted move list is the best move candidate, and I store it as "failsafe move".

Then you start the actual ID with depth 3. That is the same depth as the alpha beta minimax for the sorting, but the idea is to fill up PV and hash tables to get quicker cut-offs at depth 4+.

If you get a timeout during the ID at depth 3, you can take the failsafe move mentioned above.

Additionally and if the side to move is not in check, you can make a root null move search for getting the best move of the opponent if it were his turn to move. That is the threat detection, and this threat move can be passed to the regular ID function as probable answer move for the opponent.