Computer Chess Club Archives


Search

Terms

Messages

Subject: Hashing

Author: Frank Phillips

Date: 03:31:41 05/09/99


I have noticed that bugs in my program sometimes cause the onset of
irrationality where I bang the keyboard randomly hoping that by magic (or
perhaps the monkeys writing Shakespeare theory) the problem will go away.

Up until now I have been calculating the hash code for a position in the
ABSearch() from scratch by looping through the board and XORing the Random64
[colour_of_piece][piece][square] combinations, followed by XORing for the
enpassant square and castling rights.   To speed things up I thought I would do
this incrementally in the MakeMove() function by taking the last hash code
(always stored as wtm), undoing the enpassant and castling effects, by XORing
with same values to switch them off, then XORing to remove the piece from a
square, put piece on square, remove captured piece, add promoted piece
etc……….and then finally XORing the result for new enpassant square and castling
rights.

Everything works fine without hashing the enpassant square and castling rights,
but not otherwise.  By which I mean the new method gives the same hash code as
that calculated from scratch in the same position by looping through the board,
provided I do not hash for ep and castling.  When I print out the moves, the
offending move where it all goes wrong seems to be castling, but I cannot find
the error.

Should what I am doing work, so that there is still a bug in the incremental
hash update I have not found yet, or can I not do it the way I am trying?



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.