I was recording a video on collecting a principal variation based on implementation taken from TSCP and faced a thing that has confused me...

So here are the highlights of implementation:

Code: Select all

```
// GLOBALS
// PV length
int pv_length[64];
// PV table
int pv_table[64][64];
...
int quiescence(int alpha, int beta)
{
pv_length[ply] = ply;
....
if (score > alpha)
{
// store PV move into a PV table
pv_table[ply][ply] = move_list->moves[count];
// loop over the next ply
for (int next_ply = ply + 1; next_ply < pv_length[ply + 1]; next_ply++)
// copy move from next ply to the current line
pv_table[ply][next_ply] = pv_table[next_ply][next_ply];
// adjust PV length for the current ply
pv_length[ply] = pv_length[ply + 1];
}
}
int alphabeta(int alpha, int beta)
{
pv_length[ply] = ply;
....
if (score > alpha)
{
// store PV move into a PV table
pv_table[ply][ply] = move_list->moves[count];
// loop over the next ply
for (int next_ply = ply + 1; next_ply < pv_length[ply + 1]; next_ply++)
// copy move from next ply to the current line
pv_table[ply][next_ply] = pv_table[next_ply][next_ply];
// adjust PV length for the current ply
pv_length[ply] = pv_length[ply + 1];
}
}
```

Code: Select all

```
for (int i = 0; i < 64; i++)
{
for (int y = 0; y < 64; y++)
{
printf("%d", pv_table[i][y] ? 1 : 0);
}
printf("\n");
}
```

1. ID + PV/MVVLVA/killer/history move ordering

2. ID + PV/MVVLVA/killer/history move ordering + PVS + LMR + Null move pruning

now the move map (moves are marked as "1" empty squares by "0")

assuming search depth 5 first version (ID + PV/MVVLVA/killer/history move ordering + PVS + LMR + Null move pruning) gives:

Code: Select all

```
info score cp 30 depth 1 nodes 736 pv e2a6 b4c3
info score cp 30 depth 2 nodes 2433 pv e2a6 b4c3
info score cp 15 depth 3 nodes 9199 pv e2a6 b4c3 b2c3 e6d5
info score cp 15 depth 4 nodes 47514 pv e2a6 b4c3 b2c3 e6d5
info score cp 0 depth 5 nodes 132375 pv e2a6 e6d5 c3d5 b6d5 e4d5 e7e5
bestmove e2a6
1111110000000000000000000000000000000000000000000000000000000000
0111110000000000000000000000000000000000000000000000000000000000
0011110000000000000000000000000000000000000000000000000000000000
0001110000000000000000000000000000000000000000000000000000000000
0000110000000000000000000000000000000000000000000000000000000000
0000010000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
...
```

Code: Select all

```
info score cp 30 depth 1 nodes 774 pv e2a6 b4c3
info score cp 30 depth 2 nodes 2919 pv e2a6 b4c3
info score cp 15 depth 3 nodes 13444 pv e2a6 b4c3 b2c3 e6d5
info score cp 15 depth 4 nodes 88274 pv e2a6 b4c3 b2c3 e6d5
info score cp 0 depth 5 nodes 372537 pv e2a6 e6d5 c3d5 b6d5 e4d5 e7e5
bestmove e2a6
1111110000000000000000000000000000000000000000000000000000000000
0111111111000000000000000000000000000000000000000000000000000000
0011111111110000000000000000000000000000000000000000000000000000
0001111111111100000000000000000000000000000000000000000000000000
0000111111111100000000000000000000000000000000000000000000000000
0000011111111100000000000000000000000000000000000000000000000000
0000001111111111000000000000000000000000000000000000000000000000
0000000111111111000000000000000000000000000000000000000000000000
0000000011111111000000000000000000000000000000000000000000000000
0000000001111111000000000000000000000000000000000000000000000000
0000000000111111000000000000000000000000000000000000000000000000
0000000000011111000000000000000000000000000000000000000000000000
0000000000001111110000000000000000000000000000000000000000000000
0000000000000111110000000000000000000000000000000000000000000000
0000000000000011110000000000000000000000000000000000000000000000
0000000000000001110000000000000000000000000000000000000000000000
0000000000000000110000000000000000000000000000000000000000000000
0000000000000000010000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
...
```

I print moves like TSCP does:

Code: Select all

```
// loop over the moves within PV
for (int count = 0; count < pv_length[0]; count++)
{
// print PV move
print_move(pv_table[0][count]);
printf(" ");
}
```

Can someone please kindly explain me why is this happening?