Wing Lee wrote:Hi,
for the method using the hashtable to collect the PV, isn't it possible that one or more of the PV nodes gets replaced by another one further in the search? in this case, we can't retrieve it...
would a possible solution be to include some kind of indicator in the hash entry that would mean "do not delete" ?
Thanks
If you use the overwrite system as i described, odds are, as shown,
less than 1 in a million that you will lose more than a few ply from the
mainline.
Diep's overwrite strategy in hashtable:
- 16 bytes per entry
- 4 probes
- storing_mask = depth+searches_performed_in_game
- always overwrite the entry with lowest storing_mask
- diep is also storing in qsearch (it can do because of low nps speed)
Calculating hashtable index (each processor has its own shared hashtable):
procnr = ((((unsigned int)(hashpos.lo&0x000000000000ffff))*nprocesses)>>16);
hindex = (unsigned int)((((hashpos.lo>>16)&0x00000000ffffffff)*abmod)>>32);
hentry = &(globaltrans[procnr][hindex]);
here is code. note you might be able to get rid of some branches if
speed is a big concern in your engine:
// quadword1 = 51:key 5:flags 8:age
// quadword2 = 20:score 20:eval 2:bound 7:diepte 15:zet
//
// flags : 'vrij', matethreat, pvsingmove, egtbscore, STM
sflag = (unsigned int) side;
age = (ulzetnr+diepte2hash[ply]);
if( AllFlag&pvs_egtbentry ) {
sflag |= 2;
age += 14;
}
if( AllFlag&pvs_singularmove )
sflag |= 4;
if( AllFlag&pvs_matethreat )
sflag |= 8;
age &= 255;
s1 = ((hashpos.hi&0xffffffffffffe000)|((BITBOARD)(sflag<<8))|((BITBOARD)age));
bound = 0; // <= alfa bound
if( AllFlag&pvs_hashbound ) // score >= beta
bound |= 1; // >= beta bound
else if( AllFlag&pvs_truebound )
bound |= 2; // == true bound
if( bestscore >= -MATEVALUE+1000
&& bestscore <= MATEVALUE-1000 ) {
w2a = ((unsigned int)(bestscore+0x00080000));
}
else {
w2a = ((unsigned int)(bestscore+0x00080000+realply));
if( bestscore < 0 )
w2a -= ((unsigned int)(realply+realply));
}
s2 = (
(((BITBOARD)w2a)<<44) // !!!!! not all compilers do this correct
// as it is outside ansi-c
| (((BITBOARD)(eval+0x00080000))<<24)
| (((BITBOARD)bound)<<22)
| (((BITBOARD)ply)<<15)
| ((BITBOARD)(pvmove&0x00007fff))
);
s1 ^= s2;
hentry->key = s1;
hentry->half = s2;
#if Statistics
if( ply > 31 )
ss.stat_transstore++;
else
ss.stat_qtransstore++;
#endif