vladstamate wrote:Hi,
Yes, I am trying to store the hash entry of the position in which I have tried null move and the result came back higher than current beta. Here is what I do
Code: Select all
/* conduct a null-move search if it is legal and desired */
if (bOkNullTT && // If the TT says there is a chance we might fail high
!bPVNode &&
(depth > R+1) && // if there is enough depth available
pStart->isNullMoveOk() && // if there is at least a piece
!pStart->isChess(pStart->m_iSideToMove) )
{
pStart->makeNullMove();
/* null-move search with minimal window around beta */
iScore = -search(pStart, -iBeta, -iBeta + 1, depth - R - 1, 0);
pStart->unmakeNullMove();
if (iScore >= iBeta && !m_bOutOfTime) /* cutoff in case of fail-high */
{
g_kSearchHash.store(pStart->m_kHashKey, 0, iScore, LOWER, depth-R-1, 0);
return iScore;
}
}
One difference from the above posts is that I store the score returned by the null search and not alpha, and the node type as such is LOWER (not UPPER).
Can you see maybe something I do wrong in the above code?
Thanks in advance,
Vlad.
Here's what should happen.
You enter Search() with a remaining depth of "DEPTH". Whatever that might be is not important.
Your first task is to probe the hash table to see if you can find an entry that matches, with a draft (entry depth remaining) that is >= DEPTH. If not, you are done. If so, do whatever the entry suggests.
Assuming the entry did not allow you to terminate the search, your next stop is to do a null-move search to DEPTH - R - 1 to see if that fails high. If so, you store a hash entry for this position, with draft == DEPTH (not DEPTH - R) showing that the result is a "lower bound" (fail high condition). You must use "DEPTH" because suppose this null-move search fails high, and you later reach this same position again. Wouldn't you want to get a hash hit and fail high without going thru the null-move search overhead again?
If the null-move search does not fail high, you do a normal search, and when it finishes (either via a fail high, a fail low, or an exact score, you store that result along with DEPTH, so that the next time you reach this position you won't have to repeat this search.
Since you initially probe with a depth of DEPTH, you _must_ store draft=DEPTH so that you avoid the work the next time around... Any other value of draft will hurt. Yes, storing DEPTH-R will make your program faster, because you will be trusting that result when you should not, since you will be probing with a value of "DEPTH" and that will most certainly be >= DEPTH-R more frequently than it will be >= DEPTH. but it would be wrong in most of those cases.