Computer Chess Club Archives


Search

Terms

Messages

Subject: Correction

Author: Matthias Gemuh

Date: 16:08:12 11/21/02

Go up one level in this thread


On November 21, 2002 at 15:39:27, Robert Hyatt wrote:

>On November 21, 2002 at 12:39:24, Matthias Gemuh wrote:
>
>>On November 21, 2002 at 11:07:38, Robert Hyatt wrote:
>>
>>>On November 21, 2002 at 08:26:48, Matthias Gemuh wrote:
>>>
>>>>On November 21, 2002 at 08:15:50, Georg v. Zimmermann wrote:
>>>>
>>>>>On November 21, 2002 at 07:13:10, Vladimir Medvedev wrote:
>>>>>
>>>>>>depth = 9, from initial position:
>>>>>>
>>>>>>pawn hash = 1 entry -- 28% successful hits
>>>>>>2  --  33%
>>>>>>3  --  37%
>>>>>>4  --  38%
>>>>>>5  --  41%
>>>>>>7  --  43%
>>>>>>10 --  45%
>>>>>>100 -- 60%
>>>>>>...
>>>>>>65K -- 84%
>>>>>>
>>>>>>I was quite surprised with this :)
>>>>>>Even 1-node pawn "hash" helps a lot!
>>>>>
>>>>>Doesnt one get something around 99% with big tables ?
>>>>
>>>>
>>>>
>>>>With 2x65kB. More is not needed, if only pawns are considered.
>>>
>>>
>>>There are more possible pawn positions than that.  White has 8, black has 8.
>>>there are
>>>48 possible squares any of them can be on...  That is a pretty big number.
>>
>>
>>
>>Some hasty and wrong thinking then, when I implemented my pawn hash.
>>Maybe I somehow excluded strange positions like all pawns on 2nd and 3rd rows.
>>I shall check my code and logic later.
>>I generate keys such that they lie in range 1..2x64kB and use them as index.
>>I hit 95%..99% in middle game and WAC.
>>
>>Thanks,
>>Matthias.
>>
>>Thanks,
>>Matthias.
>
>Just one white pawn gives you 48 different positions.  one white pawn and one
>black
>pawn gives you 48*48 different positions.  or, rounding down a bit, 48 could be
>replaced by 2^5 (32).  48*48 could be approximated by 2^10 or 1024.  two more
>pawns
>and we are going to blow past 64K positions.



Without looking at my code, I explained my appraoch wrongly.
I use 64K entries as follows:


        typedef struct {
            unsigned short int PawnHashLock;
            BITBOARD PassedPawns[2], WeakPawns[2];
            short int Score;
        } PAWNHASHENTRY;

        PAWNHASHENTRY PawnHashEntry[66000]; // lazy 64K

        PawnHashKey and PawnHashLock are "unsigned short int";
        I store PawnHashLock with hash entry for verification and use
PawnHashKey as index.

    void MakePawnHashKey(HASHTABLE *HashTable, CHESSPOSITION *ChsPos) {
        register int i;
        register BITBOARD BitS;

        ChsPos->PawnHashKey = 0; ChsPos->PawnHashLock = 0;
        BitS = ChsPos->piece[0][1]; // black pawns
        while (BitS) {
            i = LastOne(BitS); BitS ^= ChsPos->Mask[i];
            ChsPos->PawnHashKey ^= HashTable->PawnHashKey[0][i];
            ChsPos->PawnHashLock ^= HashTable->PawnHashLock[0][i];
        }
        BitS = ChsPos->piece[1][1]; // white pawns
        while (BitS) {
            i = FirstOne(BitS); BitS ^= ChsPos->Mask[i];
            ChsPos->PawnHashKey ^= HashTable->PawnHashKey[1][i];
            ChsPos->PawnHashLock ^= HashTable->PawnHashLock[1][i];
        }
    }


int RetrievePawnHashEntry(HASHTABLE *HashTable, unsigned short int HashKey,
unsigned short int HashLock,
        int *Score, BITBOARD *PassedPawns, BITBOARD *WeakPawns) {
    *Score=0;

    nCounters.nPawnHashProbes++;
    if (HashTable->PawnHashEntry[HashKey].PawnHashLock != HashLock) return(0);
    *Score = HashTable->PawnHashEntry[HashKey].Score;
    PassedPawns[0] = HashTable->PawnHashEntry[HashKey].PassedPawns[0];
    PassedPawns[1] = HashTable->PawnHashEntry[HashKey].PassedPawns[1];
    WeakPawns[0] = HashTable->PawnHashEntry[HashKey].WeakPawns[0];
    WeakPawns[1] = HashTable->PawnHashEntry[HashKey].WeakPawns[1];
    nCounters.nPawnHashReads++;
    return(1);
}

This hits 95%...99%
Considering the stored verification key, we have 32 bit hashing.


Regards,
Matthias.









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.