Page 2 of 2

Re: Newbie's question about printing the PV

Posted: Sun Sep 16, 2018 12:14 am
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

Re: Newbie's question about printing the PV

Posted: Sun Sep 16, 2018 11:00 am
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.

Re: Newbie's question about printing the PV

Posted: Sun Sep 16, 2018 11:40 pm
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.)