Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Hashing of beta bound (long post)

Author: Tony Werten

Date: 02:35:11 12/07/01

Go up one level in this thread


On December 06, 2001 at 11:49:11, Michel Langeveld wrote:

>On December 06, 2001 at 08:31:44, Tony Werten wrote:
>
>>On December 06, 2001 at 07:58:14, Michel Langeveld wrote:
>>
>>>I have a problem in my program (nullmover).
>>>
>>>My program sees at an early ply (ply 7) already a mate in 5 with extensions and
>>>qsearch. This with hashing of alpha bounds and truebounds.
>>>
>>>When I hash also my beta bounds nullmover does not see it anymore. Does anybody
>>>has an idea how this could happen?
>>
>>Guessing from this little information: Your storing/retrieving of the
>>checkmatescore goes wrong.
>>
>>Tony
>>
>>>
>>>regards,
>>>
>>>Michel
>
>Thanks for the tip. I have to debug that part then. To be more precise. Here's a
>part of my source code. As you can see I have special parts for black and
>special parts for white.

OK. Now it's a bit to big :) I'll snip some parts.

>
>//////////////////////////////////////////////////////
>//Qsearch of white
>//Here only captures and promotions are searched
>//////////////////////////////////////////////////////
>scoreType qsearchWhite(scoreType alpha, scoreType beta)
>{
>   nodeCounter++;
>
>   moveListType ml;
>
>   log << cin.eof() << endl;
>   log << cin.rdbuf()->in_avail() << endl;
>
>   checkTest = attackedByBlack(p.whiteKingField);
>
>   if (isWhiteCantMove() )
>   {
>      //mate or stalemate
>      if (checkTest)  //checkTest is set in previous function
>      {
>         return -9999;

Big mistake. This works in testposition but should mess up games because you
don't make progress. You don't correct for depth. You should return something
like -9999+current_depth. You do this several times.

If you want to see the horror of this bug in optima forma, look at the game
XiniX-Ant from 2000 dutch open. XiniX had 3 queens agains a single pawn but
didn't checkmate. It eventually lost on time. ( and I only didn't correct for
depth at one place in my code)

>//////////////////////////////////////////////////////
>//Look in the hashtable if our move is present.
>//////////////////////////////////////////////////////
>scoreType probeHash(int depth, scoreType alpha, scoreType beta /*, moveType
>&bestMove*/)
>{
>   hashTableType *pHashRecord = &hashTable[p.dynHash & HASHMASK];
>
>   if (pHashRecord->key == p.dynHash)
>   {
>      if (pHashRecord->depth >= depth)
>      {
>         switch(pHashRecord->flags)
>         {
>            case HASH_FLAGS_EXACT:
>            {
>               return pHashRecord->value;
>            }
>            case HASH_FLAGS_ALPHA:
>            {
>               if (pHashRecord->value <= alpha)
>               {
>                  return alpha;
>               }
>               break;
>            }
>            case HASH_FLAGS_BETA:
>            {
>               if (pHashRecord->value >= beta)
>               {
>                  return beta;
>               }
>               break;
>            }
>         }
>      }
>   }
>
>   return HASH_UNKNOWN_VALUE;
>}

In XiniX I put something like case HASH_FLAGS_CHECKMATESCORE which means the
score I get is something like "this position is checkmate in 1" then I return
score-current_depth. (or plus if you get checkmated )
>
>
>//////////////////////////////////////////////////////
>//Record the hashmove
>//////////////////////////////////////////////////////

Before recording hash I check like "if score>9000 or score<-9000"
If true then I add (or subtract) current depth, resulting in a "pure" checkmate
value, and I change the flag to checkmatescore.

So what I do is returning a checkmatescore corrected for depth, but the result
stored in hashtable is uncorrected. ( or actually recorrected )

Tony

>void recordHash(int depth, scoreType value, int flags /*, moveType &bestMove*/)
>{
>    hashTableType *pHashRecord = &hashTable[p.dynHash & HASHMASK];
>
>    if (depth >= pHashRecord->depth)
>    {
>       pHashRecord->key = p.dynHash;
>       pHashRecord->value = value;
>       pHashRecord->flags = flags;
>       pHashRecord->depth = depth;
>       //pHashRecord->bestMove = bestMove;
>    }
>}
>



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.