Truncated Principal Variation

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
hgm
Posts: 28468
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Truncated Principal Variation

Post by hgm »

CheckersGuy wrote:Maybe I am totally confused but If I pass PVLine=true as a Parameter for the root and when I Encounter the first move of a child's sucessor node pass the pvLine Parameter and for every other move I pass pVLine=false, wouldn`t that be it ? Then pvLine would only be true if a child's parent node was a first move.

I dont know why I can't get this to work.
:x
You can also have a global array indexed by ply level, similar to the array of killers. The PV move is in fact a kind of super-killer, which you want to search even before the captures. After a node uses the PV move at its ply level, it invalidates it, so that no other node at that level will search it.

This way of implementing things is much closer to what you will eventually want: have the best move from the previous iteration in every node, and search it first. The global PV array can be seen as an extremely primitive hash table, which only stores one entry per level, so that there is no need to verify if you have a hit with the aid of some hash key, but where the probe in the PV node is always a hit, and all later probes are misses.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Truncated Principal Variation

Post by bob »

hgm wrote:
CheckersGuy wrote:Maybe I am totally confused but If I pass PVLine=true as a Parameter for the root and when I Encounter the first move of a child's sucessor node pass the pvLine Parameter and for every other move I pass pVLine=false, wouldn`t that be it ? Then pvLine would only be true if a child's parent node was a first move.

I dont know why I can't get this to work.
:x
You can also have a global array indexed by ply level, similar to the array of killers. The PV move is in fact a kind of super-killer, which you want to search even before the captures. After a node uses the PV move at its ply level, it invalidates it, so that no other node at that level will search it.

This way of implementing things is much closer to what you will eventually want: have the best move from the previous iteration in every node, and search it first. The global PV array can be seen as an extremely primitive hash table, which only stores one entry per level, so that there is no need to verify if you have a hit with the aid of some hash key, but where the probe in the PV node is always a hit, and all later probes are misses.
Why not just make certain that the PV moves are ALL in the hash table before the next iteration starts? Now you have no extra code, no extra memory references, no extra branches to handle, etc, because surely everyone searches the hash move first at a node where one is available?