Page 1 of 1

NULL Move code question

Posted: Fri Jan 27, 2017 5:49 pm
by thevinenator
Consider the CPW code for NULL Move...

Code: Select all

	if (depth > 2
		&&   can_null
		&&  !is_pv
		&&   eval(alpha, beta, 1) > beta
		&&   b.piece_material[b.stm] > e.ENDGAME_MAT
		&&  !flagInCheck)
	{
		char ep_old = b.ep;
		move_makeNull();

		/**********************************************************************
		*  We use so-called adaptative null move pruning. Size of reduction   *
		*  depends on remaining  depth.                                       *
		**********************************************************************/
		char R = 2;
		if (depth > 6) R = 3;

		val = -Search(depth - R - 1, ply + 1, -beta, -beta + 1, NO_NULL, NO_PV);

		move_unmakeNull(ep_old);

		if (time_over) return 0;
		if (val >= beta) return beta;
	}   // end of null move code
I'm questioning the first condition (depth > 2)....

When the call to Search is made, the depth passed to the search will have the following values, based on the original depth.

Org Depth Search Depth
0 n/a
1 n/a
2 n/a
3 0
4 1
5 2
6 3
7 3

Consider org depth of 3. search() will be called with an effective depth of 0 and will drop into QSearch() (in my implementation unless there is a depth extension) and won't do any further search. is that really part of the idea of the Null Move ? Seems to me the threshold for dropping into search() should only occur if a another recursive call to search() can be made.

Is this how others implement it?

Re: NULL Move code question

Posted: Fri Jan 27, 2017 6:02 pm
by H.G.Muller
I always use the condition depth > 0. I.e. I don't do null move in QS (d <= 0), but do it for any higher depth. At d=1, 2 and 3 the reply is QS. If the null move fails high at d=3, (meaning that in QS the opponent could not grab enough material to worry me), I should not expect the d=3 search of my best real move to fail low. Because even if the opponent could set up something that would pay off on ply 4 (his first QS ply), I will almost always be able to prevent that with my move at ply 1 (which I can freely use, as there was no immediate threat). So doing a d=3 search is a waste of time.

Re: NULL Move code question

Posted: Wed Feb 08, 2017 5:43 pm
by pkumar
H.G.Muller wrote:I always use the condition depth > 0. I.e. I don't do null move in QS (d <= 0), but do it for any higher depth. At d=1, 2 and 3 the reply is QS.
This is reasonable. I wonder why the cpw code in the original post uses the condition depth>2 .