# Computer Chess Club Archives

## Messages

### Subject: Where is Principal Variation?

Author: Severi Salminen

Date: 08:25:19 11/22/00

```Hi!

There is something wrong in my chess program. I'm trying to search the PV moves
first, then the captures and then non_captures. A question:

Does a move belong to PV _allways_ when its score is >alpha and <beta? And can I
use this assumption to find all PV moves by backing up from PV leaf to root?

My program has a separate root_search() and search(). In search I first check
wheteher the last move was a PV move and then if we still have moves left in PV
it swaps the first generated move and the PV move for that ply. Then we make
moves (so the first is the PV move). And allways when I have alpha<score<beta I
make the move we tried a PV move for that ply. For some unknown reason a certain
position results a situation where my program tries to make a PV move which is
not possible. The PV points to a move that is not in the move list of current
ply.

// Here I test whether the last move was PV move and we have still PV moves
// left

if((Follow_PV[Ply-1]==1)&&(PV_lenght>Ply))
swap_moves(&Moves[Firstmove[Ply]],&Moves[PV[Ply]]);

// Here I test if the move we made was a PV move
makemove(Moves, k, ptr);
if((k==Firstmove[Ply])&&(Follow_PV[Ply-1]==1)&&(PV_lenght>Ply))
Follow_PV[Ply]=1;
else Follow_PV[Ply]=0;

// This is done if beta>score>alpha
// This basically avoids any problems because of the swapping we made
if((Follow_PV[Ply-1]==1)&&(PV_lenght>Ply))
{
if(k==PV[Ply])
PV[Ply]=Firstmove[Ply];
else if(k!=Firstmove[Ply])
PV[Ply]=k;
}
else
PV[Ply]=k;

Any suggestions? (It was a bit unclear explanation, but...)

Severi

```