Author: Robert Hyatt
Date: 20:04:40 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?
Mate should be stored as "mate in N moves from the current position". But
mate scores within the search are computed as "mate in N moves from the root
tree position". I simply convert from mate from root to mate from current
position with the above...
>2) What is the reason to have Min(value,MATE-300) or Max(value,-MATE+300) when
>type == LOWER or UPPER?
It was just a quick fix to a problem I had years ago. When I am storing a
mate _bound_ I simply store MATE-300 or -MATE+300 only, rather than other
mate bounds that might exist... You can do the same thing to the bounds
that I do to the real mate score if you want, and it would be correct...
>3) What is the reason to add 65536 to value?
Makes value _always_ positive so the shifting/oring won't have sign
extension bits (2's complement math) that would corrupt other parts of
the packed word... Value can _never_ be less than -65536, so that if I
add +65536 to it, value will always be >= 0 and the sign and related
bits will be zero.
>4) What is the reason to do exclusive or(^) to get word2?
>
That is a trick used for parallel searching. It is explained in the
current issue of the JICCA. If you are not doing a parallel search,
you can eliminate that everywhere.
>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.