Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: keeping track of PV and using hashed results

Author: Dezhi Zhao

Date: 01:28:25 01/16/99

Go up one level in this thread


On January 15, 1999 at 14:21:16, GBes wrote:

>Hi all,
>
>a month ago i start writing a chessprogram.
>The part of the program that generates moves ( with bitboards )
>works fine, also the hashtable seems to work.
>
>The evaluation function returns simply (-MATE + ply) or 0;
>
>For the alpha/beta search i have trouble with keeping track
>of the principal variation.
>
>After doing a HashProbe that returns EXACT, i have a BestMove and its Score
>from the hashtable.
>What i don't have is the sequence of moves that comes after this BestMove.
>This okay if BestMove is not part of the PV after all (IMHO)
>but if it is then i only have a first part of the PV, and i want more...
>
>so my question is :
>
>"How to keep track of the principal variation when using results from the
>hashtable ?"
>
>Hope someone can shine some light over this
>
>thanks a lot gerritbes.
>
>
>this is how i am doing it now :
>
>int ABSearch( alpha, beta, depth, ply )
>{
>   if ( depth == 0 ) return Evaluate();
>
>   switch ( HashProbe( hashKey, depth, ply, *lHashScore, *lHashMove ) )
>   {
>      case EXACT:
>                 if ( alpha < lHashScore < beta )
>                 {
>                   // could return lHashScore here
>                   // but then don't have the PV ?????
>                   // so... continue
>                 }
>                 else
>                 {
>                   return lHashScore;
>                 }
>      break;
>   }
>
>   while ( lMoreMove )
>   {
>      // calls to ABSearch...
>   }
>
>   // update PV if a move was found in while loop
>   if ( initial_alpha < alpha < beta )
>   {
>     PV_Moves[ply][0] = lBestMove_found_in_while_loop;
>     PV_Moves[ply][1...] = PV_Moves[ply+1][0...];
>     PV_Moves[ply+1].Empty();
>
>     // also store here this position with type = EXACT in hashtable
>
>   }
>   else
>   {
>     // PV_Moves[ply] is empty
>     // or contains MoveSequence that leads to score alpha (IMHO)
>   }
>
>   return alpha;
>}

I don't think this is a big problem if the pv line is cut
short by a transpoition table hit in rare cases.
I think the pv line is mainly for debug purpose today. If you really
care of what the contiuation of the hash move is, you may find it
out after the iterative deepening and before dumping the pv.  You may
make all the available moves in pv and reach the position where the
pv is cut short, and do a probe and get the hash move, then make the hash
move, and probe again....  Of course,  you need to unmake all these moves
after you find the hiden pv moves.  You may not get the all pv moves if
a pv entry in hashtable was overwriten, but it would be really rare.
To implement this, you also need to add a hash-hit flag in the pv record
to remind the pv-dump routine that the pv is cut short.

And I see no reason why you compare the hash score with alpha-beta in
the EXACT case of your sample code. The only thing you can do with exact
score is to set the pv length of the ply to zero and return the score.

Best Regards

Dezhi Zhao




This page took 0 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.