Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Crafty hash table question

Author: Gerd Isenberg

Date: 10:32:25 08/12/02

Go up one level in this thread


On August 12, 2002 at 10:53:59, Patrik wrote:

>void HashStore(TREE *tree, int ply, int depth, int wtm, int type,
>               int value, int threat) {
>
>  word1l=((((transposition_id<<2)+type)<<1)+threat)<<26;
>  if (type == EXACT) {
>    if (value > MATE-300) value=value+ply-1;		---------> question 1
>    else if (value < -MATE+300) value=value-ply+1;	---------> question 1
>    if ((int) tree->pv[ply].pathl >= ply)
>      word1l|=tree->pv[ply].path[ply];
>  }
>  else if (type == LOWER) {
>    word1l|=tree->current_move[ply];
>    value=Min(value,MATE-300);    ----------------> question 2
>  }
>  else {
>    value=Max(value,-MATE+300);   ----------------> question 2
>  }
>  word1r=(depth<<17)+value+65536;						----------------> question 3
>  word1=word1r+((BITBOARD)word1l<<32);
>  word2=(wtm) ? HashKey : ~HashKey;
>  htablea=trans_ref_a+((int) word2&hash_maska);
>  draft=(int) htablea->word1>>17 & 077777;
>  age=htablea->word1>>61;
>  age=age && (age!=transposition_id);
>  if (age || (depth >= draft)) {
>    if ((word1^word2) != htablea->word2) {
>      htableb=trans_ref_b+((int) (htablea->word2)&hash_maskb);
>      htableb->word1=htablea->word1;
>      htableb->word2=htablea->word2;
>    }
>    htablea->word1=word1;
>    htablea->word2=word1^word2;	----------------> question 4
>  }
>  else {
>    htableb=trans_ref_b+((int) word2&hash_maskb);
>    htableb->word1=word1;
>    htableb->word2=word1^word2;	----------------> question 4
>  }
>}
>
>
>
>Hello, Dr. Hyatt.
>
>I have some questions about hash table.
>
>1) What is the reason to add or subtract ply when value > MATE-300 or value <
>-MATE+300?

Since mate or "get mated" values are dependend from ply distance to root, they
are adjusted before stroring and after probing. Due to different search pathes,
the ply distance to root (ply) may be different, if a probe hit occurs with an
exact mate or "get mated" value.

>2) What is the reason to have Min(value,MATE-300) or Max(value,-MATE+300) when
>type == LOWER or UPPER?

The same reason as q1. Simply stores the lowest value interpreted as mate
(MATE-300) as lower bound (big enough to cause a beta cutoff elsewhere in the
tree), or highest "get mated" value as upper bound.

>3) What is the reason to add 65536 to value?

This avoids trouble with negative integers after storing them in bitfields via
mask and shift, but don't forget to subtract after probing.

>4) What is the reason to do exclusive or(^) to get word2?

See Hyatt's/Mann's note in latest ICGA-Journal (Vol.25 March02):
 "A LOCKLESS TT IMPLEMENTATION FOR PARALLEL SEARCH"


>Anybody can answer to my question.
>Thank you in advance.

Gerd



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.