Transposition Tables
Posted: Sat Jan 12, 2013 3:41 am
Hello, time for yet another question (sorry if I have so many ). Basically I've just integrated transposition tables in and I'm having trouble figuring out a bug. My program is being written in java. Using transposition tables causes it to fail to see a mate in 5 ply even if it is evaluating to a deeper ply than that. In my code the transposition table is a HashMap of type <Long, int[] >.
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:
I am using a zobrist hash key. the zobrist hash function and move hashing function is working perfectly, I've verified that with extensive tests. Also, I very much doubt that I am getting a collision of hashes between new positions because I am analyzing maybe 1 million positions per move ( if i'm lucky) and I've also tried several different seeds for my RNG.
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
}