Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: how to back up the PV with minimal work.

Author: Robert Hyatt

Date: 18:52:53 01/19/04

Go up one level in this thread


Here is what I do.  Dirt-simple.  No extra work:



      memcpy(&tree->pv[ply - 1].path[ply], &tree->pv[ply].path[ply],
          (tree->pv[ply].pathl - ply + 1) * sizeof(int));

The above copies all the PV moves that were backed up to this ply back one
ply.  Note that if I am at ply=10, I copy the PV for ply=11 to the end of the
PV to the previous ply.



      memcpy(&tree->pv[ply - 1].pathh, &tree->pv[ply].pathh, 3);

That copies a flag which tells how the PV was terminated, ie via a hash
hit, egtb hit, etc.



      tree->pv[ply - 1].path[ply - 1] = tree->current_move[ply - 1];


Finally I copy the best move at the _current ply_ into the PV for the
previous ply.  To count the work done, if doing a 10 ply search with no
extensions, at ply=10 all I do is store the current move at ply=9 in path[10].
When I finish 9, I copy that one word back to ply 8 and then stuff my best
move in at path[9].

By the time I get to the root I have copied 10+9+8+7+...+1 words total.  I
had been intending to simplify this a bit further, but it has no cost and I
have not done anything else.  Using a special "sentinel" isn't quite as clean
for me as I have a pathl value that tells me how many moves are in the PV,
so that I can tell memcpy() how much stuff needs copying.

I could copy the entire path each time I back it up, but that is extra traffic
that is not needed.




This page took 0.01 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.