Newbie's question about printing the PV

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
maksimKorzh
Posts: 771
Joined: Sat Sep 08, 2018 5:37 pm
Location: Ukraine
Full name: Maksim Korzh

Re: Newbie's question about printing the PV

Post by maksimKorzh »

I actually did it, but forgot to add to post, the declaration is

Code: Select all

int *pvStart = pvPtr; // start of own PV
*pvStart = 0; // initialize empty PV at the top of the PV stack
At the moment I'm experimenting with triangular pv you've mentioned,
I use pvTable[64][64] array to store pv and it seems to work fine, but
there also has to be tracked pv_length[64], I just wonder how does
H.G.Muller's method work without knowing the length.

To be honest I've stalled tscp's implementation because the chess programming wiki's
triangular pv pseudo code implementation was a bit complicated to understand


-----------------------------------------------------------------------------------
Maksim Korzh
Chenglite
https://github.com/maksimKorzh/Chenglite
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Newbie's question about printing the PV

Post by Sven »

maksimKorzh wrote: Sun Sep 16, 2018 12:14 am At the moment I'm experimenting with triangular pv you've mentioned,
I use pvTable[64][64] array to store pv and it seems to work fine, but
there also has to be tracked pv_length[64], I just wonder how does
H.G.Muller's method work without knowing the length.
I do not know HGM's method in detail but all triangular PV implementations that I know work with a "zero" marker, just like strcpy(), so you don't need to track the PV length at each level.
Sven Schüle (engine author: Jumbo, KnockOut, Surprise)
User avatar
hgm
Posts: 27787
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Newbie's question about printing the PV

Post by hgm »

Oops, my bad! :oops: I should have written

*pvPtr++ = 0;

for initializing the empty PV. This line writes the 0 'sentinel' that indicates the end of each PV that Sven is talking about (assuming 0 is not the code for any posisble move). At this point in the code pvPtr and pvStart are equal, but it is essential to increment pvPtr (which must point to the first non-used entry in pvStack), to make sure the 0 is not overwritten. (Which would then join two PVs of different levels in the tree, appending false moves at the end, like you see happening.)