His code is very beautifully written. In addition, it is also written in a robust way (it is quite remarkable for a body of code that large to emit so few compiler warnings).
Quite surprisingly, the function with the most time is cheng4::TransTable::probe at 7.51% of inclusive time. For most high level programs, the dominant time is spent in eval().
Code: Select all
// probe hash table
// returns scInvalid if probe failed
Score TransTable::probe( Signature sig, Ply ply, Depth depth, Score alpha, Score beta, Move &mv ) const
{
mv = mcNone;
size_t ei = ((size_t)sig & (size-1) & ~(buckets-1));
const TransEntry *te = entries + ei;
TransEntry lte;
for ( uint i=0; i<buckets; i++, te++)
{
lte = *te; // ! The lion's share of the time is in this assignment, duplicating a copy of the hash entry.
lte.bhash ^= lte.u.word2;
if ( lte.bhash == sig )
{
mv = lte.u.s.move;
if ( lte.u.s.depth < depth )
return scInvalid;
BoundType bt = (BoundType)(lte.u.s.bound & 3);
Score score = ScorePack::unpackHash( lte.u.s.score, ply );
switch ( bt )
{
case btExact:
return score;
case btUpper:
if ( score <= alpha )
return score;
break;
case btLower:
if ( score >= beta )
return score;
break;
default:
return scInvalid;
}
}
}
return scInvalid;
}
Code: Select all
// lte = *te; // The lion's share of the time is in this assignment, duplicating a copy of the hash entry.
// lte.bhash ^= lte.u.word2;
if ( (te->bhash ^ lte->u.word2) == sig )
I notice that his hash table is 4 levels deep (deeper than many others).