Computer Chess Club Archives


Search

Terms

Messages

Subject: Crafty hash table question

Author: Patrik

Date: 07:53:59 08/12/02


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?
2) What is the reason to have Min(value,MATE-300) or Max(value,-MATE+300) when
type == LOWER or UPPER?
3) What is the reason to add 65536 to value?
4) What is the reason to do exclusive or(^) to get word2?

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



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.