Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Transposition table replacement.

Author: Harald Lüßen

Date: 12:57:44 07/29/04

Go up one level in this thread


On July 29, 2004 at 13:55:37, Eric Oldre wrote:

>
>I have a couple theories about trans table replacement that i'd like some input
>on.
>
>I started off with a single replace if deeper trans table.
>
...
>
>then I wanted to try something else. I was going to look not just at the entry
>exactly at &trans_table.entries[board->zobrist0%trans_table.size];
>but also the few entries following that entry.
>
...
>
>with the idea that if there was a lower depth entry near the address that it
>would normally
>replace at, then it would replace the lowest depth entry in that area. keeping
>more valuable deeper entries.
>
>I discovered that instead of reducing my node counts it actually went up.
>
>my question is, does the above approach make since? it seems it would reduce
>my node count to me, but perhaps i'm missing something.
>
>Or does that fact that it increased my node count point to suggest
>that I have other problems in my trans table use?
>
>Also, if the 2nd method above is fairly common, is there a common
>term for that type of scheme?
>
>Thanks,
>Eric

I use something similar and it works, but I plan to
improve it when I have the time ...

#define HASH_SHEME_BEST_OF_MANY() (1)
#define NUMBER_OF_HASH_ENTRIES 2

void HashTable::store_info( ... )
{ ...
    long key = position.hash_.get_key();
#if HASH_SHEME_ALWAYS_REPLACE()
    // overwrite everything
    hash_table_[key] = entry;
    hash_entries_++;
#else // HASH_SHEME_BEST_OF_MANY()
    // overwrite shorter lines
    long best_key = key;
    short best_key_distance = hash_table_[key].distance();
    int i;
    for ( i = 0; i < NUMBER_OF_HASH_ENTRIES; ++i )
    {
        HashEntry &old_entry = hash_table_[key];
        if ( old_entry.is_free() )
        {
            // fill free entries
            old_entry = entry;
            hash_entries_++;
            return;
        }
        else if ( entry.code_ == old_entry.code_ )
        {
            // update entry
            old_entry = entry;
            return;
        }
        else if ( old_entry.distance() < best_key_distance )
        {
            // In case there is no free entry, this place is not so bad
            best_key = key;
            best_key_distance = old_entry.distance();
        }
        key = position.hash_.get_next_key( key );
    }
    if ( distance > best_key_distance )
    {
        // use unimportant entry
        hash_table_[best_key] = entry;
    }
    // forget this entry
#endif
}

bool HashTable::lookup_info( ... )
{
    long key = hash.get_key();
    for ( int i = 0; i < NUMBER_OF_HASH_ENTRIES; ++i )
    {
        const HashEntry &ht_entry = hash_table_[key];
        if ( ht_entry.is_free() )
            break;
        if ( ht_entry.code_ == hash.get_code() )
        {
            entry = ht_entry;
            // Correction for mate values
            ...
            ++hash_hits_;
            return true;
        }
        key = hash.get_next_key( key );
    }
    ++hash_misses_;
    return false;
}

Any comments anyone?

Harald




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.