Page 1 of 6
PVS & Embla
Posted: Thu Oct 19, 2017 8:32 pm
by flok
Hi,
I'm trying to add PVS to Embla.
I've added almost exact the code from
https://chessprogramming.wikispaces.com ... seudo Code
to it but to my surprise it lost almost 50 elo.
I've probably overlooked a - or + or something somewhere but I'm not seeing it.
Anyone willing to look at it?
All the code is available
https://github.com/flok99/Embla/tree/PVS
(Brain.cpp, method is ::search() )
regards
Re: PVS & Embla
Posted: Thu Oct 19, 2017 8:52 pm
by AlvaroBegue
If your transposition tables are working well, PVS should not lose Elo. I haven't read your code, but I can give you the pseudo-code for what I do.
Code: Select all
int negamax(Board &board, int alpha, int beta, int depth) {
if (depth <= 0)
return quiescence_search(board, alpha, beta);
for (int i = 0; i < board.n_moves(); ++i) {
board.make_move(i);
if (i > 0) {
int reduction = 0; // for now; you can implement LMR here
score = -negamax(-alpha-1, -alpha, depth - 1 - reduction);
if (score <= alpha) {
board.unmake_move();
continue;
}
if (score >= beta && reduction == 0)
goto DONE;
}
int score = -negamax(-alpha, -beta, depth - 1);
DONE:;
board.unmake_move();
if (score > alpha) {
alpha = score;
if (alpha >= beta)
break;
}
}
return alpha;
}
Re: PVS & Embla
Posted: Thu Oct 19, 2017 8:53 pm
by AndrewGrant
Are you using fail-soft or fail-hard?
Re: PVS & Embla
Posted: Thu Oct 19, 2017 8:56 pm
by elcabesa
i think that line 1119 is wrong.
Code: Select all
if (bSearchPV)
retry:
score = -search(sd, &m, depthLeft - 1 + extension, co, -beta, -alpha, newHash, curBestSiblings, false, &tempPv);
else {
score = -search(sd, &m, depthLeft - 1 + extension, co, -alpha - 1, -alpha, newHash, curBestSiblings, false, &tempPv);
!!! WRONG!!! if (score > alpha && score < beta) !!! WRONG!!!!!!
goto retry;
}
it should probably be :
because the search in the above line ha limits [alpha, alpha+1] and not [alpha,beta]
[/code]
Re: PVS & Embla
Posted: Thu Oct 19, 2017 8:57 pm
by flok
AndrewGrant wrote:Are you using fail-soft or fail-hard?
Fail soft: the returned score can be outside the bounds.
regards
Re: PVS & Embla
Posted: Thu Oct 19, 2017 9:05 pm
by flok
I'm going to test that. I don't fully understand it because the wiki says that fail-soft should also check for score < beta?
Re: PVS & Embla
Posted: Thu Oct 19, 2017 9:14 pm
by tomitank
Hi flok!
I think, the biggest wasted time here:
Code: Select all
if (useNm && !rootOfTree && nmDepth > 0 && !isCheck && !isNullMove)
add to
Code: Select all
IS_PV = (beta != alpha + 1);
and
Code: Select all
if (!IS_PV && useNm && nmDepth > 0 && !isCheck && !isNullMove)
(root node = Pv node)
Try this by IID as well.
Your code is difficult to understand for me.
Try to clean the code and you'll notice where the bug is.
Re: PVS & Embla
Posted: Thu Oct 19, 2017 9:40 pm
by flok
That sounds interesting!
A quick TTD test showed no improvement (it got only slower) but maybe a longer run shows better results (I've started that).
thanks
Re: PVS & Embla
Posted: Thu Oct 19, 2017 10:26 pm
by elcabesa
what version of GCC compiler are you using?
because I'm trying to copile it with the makefile you provide, but it doesn't work on my PC
Re: PVS & Embla
Posted: Thu Oct 19, 2017 10:41 pm
by Sven
According to the "Compare" function on github your branch "PVS" seems to have more diffs to the master branch than just the PVS change. This could explain the surprising results. Maybe you had checked out the wrong branch when making the "PVS" branch?