Newbie's question about printing the PV

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.
maksimKorzh
Posts: 54
Joined: Sat Sep 08, 2018 3:37 pm
Location: Ukraine
Full name: Maksim Korzh
Contact:

Re: Newbie's question about printing the PV

Post by maksimKorzh » Sat Sep 15, 2018 10:14 pm

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

Re: Newbie's question about printing the PV

Post by Sven » Sun Sep 16, 2018 9:00 am

maksimKorzh wrote:
Sat Sep 15, 2018 10:14 pm
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: 22588
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: Newbie's question about printing the PV

Post by hgm » Sun Sep 16, 2018 9:40 pm

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.)

Post Reply