PVS & Embla

Discussion of chess software programming and technical issues.

Moderators: hgm, Harvey Williamson, bob

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
flok

PVS & Embla

Post by flok » Thu Oct 19, 2017 6:32 pm

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

Re: PVS & Embla

Post by AlvaroBegue » Thu Oct 19, 2017 6:52 pm

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: 435
Joined: Tue Apr 19, 2016 4:08 am
Location: U.S.A
Full name: Andrew Grant
Contact:

Re: PVS & Embla

Post by AndrewGrant » Thu Oct 19, 2017 6:53 pm

Are you using fail-soft or fail-hard?

elcabesa
Posts: 779
Joined: Sun May 23, 2010 11:32 am
Contact:

Re: PVS & Embla

Post by elcabesa » Thu Oct 19, 2017 6:56 pm

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 » Thu Oct 19, 2017 6:57 pm

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 » Thu Oct 19, 2017 7:05 pm

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: 192
Joined: Sat Mar 04, 2017 11:24 am
Location: Hungary

Re: PVS & Embla

Post by tomitank » Thu Oct 19, 2017 7:14 pm

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 » Thu Oct 19, 2017 7:40 pm

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: 779
Joined: Sun May 23, 2010 11:32 am
Contact:

Re: PVS & Embla

Post by elcabesa » Thu Oct 19, 2017 8:26 pm

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

Re: PVS & Embla

Post by Sven » Thu Oct 19, 2017 8:41 pm

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?

Post Reply