Author: Sune Fischer
Date: 10:37:21 04/08/02
Go up one level in this thread
On April 08, 2002 at 12:38:35, John Marountas wrote:
>Hello again !
>
>First of all, I want to thank those who replied at my question
>on Debugging the HashTables implementation.
>
>Obviously I had forgoten to mask the info about the side to move and
>the castle and ep rights into the HashKey. I fixed that by using the code below.
>I think the code is correct.
>
>//************************************************
>int ZobristKey(int side) throws IOException{
> int hashKey = 0;
>
> for(int p=0;p<64;p++){
> hashKey ^=zobrist[side][ brd.piece[p] ][p];
> }
>
> hashKey ^= side; //Side to move
> hashKey ^= ep_to; //Ep rights
> hashKey ^= castle; //Castle rights
>
> return hashKey;
>}
>//************************************************
I see a few problems with this, e.g. if ep_to=1 and side=1, they will just
cancel each other. Better to use full 64-bit keys for everything.
Also if you do it incrementally, then you need to remove the keys again when
they are no longer "active".
With the side-to-move key, I set the first bit if white and remove it if black.
It has the advantage that I can always tell by the key itself who's to move, and
it can be done without an "if" which is also nice, I don't see any problems with
that (except spending an entire bit on just the color is a bit of a waste).
>Then I run Pyotr and setup the following position:
>
>[D] r1bqkbnr/pppp1ppp/2n5/4p3/3PP3/5N2/PPP2PPP/RNBQKB1R b KQkq d3 0 3
>
>
>
>When searching into the HashTable I keep a record of the returned
>Lows,Highs and Hash Collisions. Here are the results:
>
>Hash Collisions: 1000
>Hash High : 173
>Hash Low : 0
>
>Best Move : 3...Nxd4
>
>Why there are so many collisions?
What do you mean by "collisions", the same key for different positions?
How did you test for that, perhaps that's where the error is?
-S.
>Then I continue the position by playing 4.Nxd4 and got the following results.
>Hash Collisions: 2280
>Hash High : 31
>Hash Low : 1
>
>Best Move : 4...e5xd4
>
>Again notice the hight of the Hash Collisions and the low of the other two
>numbers.
>Does any of these numbers has to do with my wrong implementation ?
>
>Thank in advance !
>Marountas John
>
>Pyotr's Website : http://www.digichess.gr/pyotr/
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.