PVS & Embla

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

flok

PVS & Embla

Post 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
AlvaroBegue
Posts: 931
Joined: Tue Mar 09, 2010 3:46 pm
Location: New York
Full name: Álvaro Begué (RuyDos)

Re: PVS & Embla

Post 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 &#40;depth <= 0&#41;
    return quiescence_search&#40;board, alpha, beta&#41;;
  
  for &#40;int i = 0; i < board.n_moves&#40;); ++i&#41; &#123;
    board.make_move&#40;i&#41;;
    if &#40;i > 0&#41; &#123;
      int reduction = 0; // for now; you can implement LMR here
      score = -negamax&#40;-alpha-1, -alpha, depth - 1 - reduction&#41;;
      if &#40;score <= alpha&#41; &#123;
        board.unmake_move&#40;);
        continue;
      &#125;
      if &#40;score >= beta && reduction == 0&#41;
        goto DONE;
    &#125;
    int score = -negamax&#40;-alpha, -beta, depth - 1&#41;;
DONE&#58;;
    board.unmake_move&#40;);
    if &#40;score > alpha&#41; &#123;
      alpha = score;
      if &#40;alpha >= beta&#41;
        break;
    &#125;
  &#125;
  
  return alpha;
&#125;

AndrewGrant
Posts: 1750
Joined: Tue Apr 19, 2016 6:08 am
Location: U.S.A
Full name: Andrew Grant

Re: PVS & Embla

Post by AndrewGrant »

Are you using fail-soft or fail-hard?
#WeAreAllDraude #JusticeForDraude #RememberDraude #LeptirBigUltra
"Those who can't do, clone instead" - Eduard ( A real life friend, not this forum's Eduard )
elcabesa
Posts: 855
Joined: Sun May 23, 2010 1:32 pm

Re: PVS & Embla

Post by elcabesa »

i think that line 1119 is wrong.

Code: Select all

if &#40;bSearchPV&#41;
				retry&#58;
					score = -search&#40;sd, &m, depthLeft - 1 + extension, co, -beta, -alpha, newHash, curBestSiblings, false, &tempPv&#41;;
				else &#123;
					score = -search&#40;sd, &m, depthLeft - 1 + extension, co, -alpha - 1, -alpha, newHash, curBestSiblings, false, &tempPv&#41;;
!!! WRONG!!!				if &#40;score > alpha && score < beta&#41;   !!! WRONG!!!!!!
						goto retry;
&#125;
it should probably be :

Code: Select all

if&#40;val>alpha&#41;
because the search in the above line ha limits [alpha, alpha+1] and not [alpha,beta]
[/code]
flok

Re: PVS & Embla

Post by flok »

AndrewGrant wrote:Are you using fail-soft or fail-hard?
Fail soft: the returned score can be outside the bounds.


regards
flok

Re: PVS & Embla

Post 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?
tomitank
Posts: 276
Joined: Sat Mar 04, 2017 12:24 pm
Location: Hungary

Re: PVS & Embla

Post by tomitank »

Hi flok!

I think, the biggest wasted time here:

Code: Select all

if &#40;useNm && !rootOfTree && nmDepth > 0 && !isCheck && !isNullMove&#41;
add to

Code: Select all

IS_PV = &#40;beta != alpha + 1&#41;;
and

Code: Select all

if (!IS_PV && useNm && nmDepth > 0 && !isCheck && !isNullMove&#41;
(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.
flok

Re: PVS & Embla

Post 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
elcabesa
Posts: 855
Joined: Sun May 23, 2010 1:32 pm

Re: PVS & Embla

Post 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
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: PVS & Embla

Post 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?