Before the start of the cpu's turn, after the user has made their move, the table is cleared. Then I use the code like this:
Code: Select all
// inside the alphabeta search
tempHash = hashMove( move, currentHash ); // Hashes in the move to the current positional hash. Takes into account castling
int[] info = hashTable.get( new Long( tempHash ) ); // info, contains two ints, a value for the search and the depth it was searched to.
if ( info != null && info[0] >= currentDepth - depth ) // If we get a hit, and the depth for the value in the hashmap is large enough
return info[1]; // Return the value stored in the hash table
}
// perform actual search of move...
if ( info == null ) {
info = new int[2];
info[0] = currentDepth - depth;
info[1] = SCORE_OF_EVALUATED_MOVE;
hashTable.put( new Long( tempHash ), info ); // Store the value and depth and hash
}