PV test and PVS
Posted: Fri Jun 08, 2018 9:13 pm
I'm debugging a run time error in some new code and found a situation that isn't intuitive.
entering a node i apply the PV test...
in this test example, alpha = 123 and beta is 124, so, bIsPV is false, indication we are not in the PV
entering the move loop, the first move available is made, bumping the MoveCount variable from 0 to 1 and then we reach the PVS code. I coded the PVS code to what I "thought" was the correct way to do it, so....
Now wait a minute. the bIsPV test says we aren't in the PV, but the logic for the PVS indicates that the first move should be search full width. Which is correct? Should the PVS code actually read...
is the bIsPV test 100% accurate?
entering a node i apply the PV test...
Code: Select all
bool bIsPV = (alpha != beta - 1);entering the move loop, the first move available is made, bumping the MoveCount variable from 0 to 1 and then we reach the PVS code. I coded the PVS code to what I "thought" was the correct way to do it, so....
Code: Select all
if (MoveCount == 1) { // haven't searched yes, so PV
v = -ABTTFH(&p1, -beta, -alpha, NewDepth, &cPV, NM::NM_ALLOWED);
}
else {
v = -ABTTFH(&p1, -alpha - 1, -alpha, NewDepth, &cPV, NM::NM_ALLOWED);
if ((v > alpha) && (v < beta))
v = -ABTTFH(&p1, -beta, -alpha, NewDepth, &cPV, NM::NM_ALLOWED);
}
Code: Select all
if (bIsPV) { // whether we are trying the first move or not...
v = -ABTTFH(&p1, -beta, -alpha, NewDepth, &cPV, NM::NM_ALLOWED);
}
else {
v = -ABTTFH(&p1, -alpha - 1, -alpha, NewDepth, &cPV, NM::NM_ALLOWED);
if ((v > alpha) && (v < beta))
v = -ABTTFH(&p1, -beta, -alpha, NewDepth, &cPV, NM::NM_ALLOWED);
}