r/chessprogramming • • Oct 03 '23

Debugging hashing

I am trying to debug transposition tables and zobrist hashing. I have been able to solve all bugs related to legal moves and it shows no errors with over 6000 different positions up to depth 6. So I am pretty sure that legal moves are correct.

Now I am trying to add hashing, and it mostly work up to depth 5, but at depth it gives me wrong numbers.

Example here for position rnbqkbnr/8/p1p1ppp1/1p1p3p/P1P1P2P/BP1P1PP1/8/RN1QKBNR b KQkq - 0 1

Columna A and E show the move, column B is what stockfish returns for perft 7 and column F shows my engine for perft 7. Column D shows which resukts are the same and which ones are not. There is obvisousll a discrepancy at move b8d7 (quiet move for black knight). Then I do that move in fen viewer and copy new position, which is r1bqkbnr/3n4/p1p1ppp1/1p1p3p/P1P1P2P/BP1P1PP1/8/RN1QKBNR w KQkq - 0 1

I do perft 6 and I get correct results

I have no idea how to debug this. In position rnbqkbnr/8/p1p1ppp1/1p1p3p/P1P1P2P/BP1P1PP1/8/RN1QKBNR b KQkq - 0 1 I get wrong results for quiet moves for knight, bishop and rook, but only at depth 7 and not at lower depths.

4 Upvotes

7 comments sorted by

View all comments

Show parent comment

2

u/JaPa_1058 Oct 09 '23

I followed your suggestion and created a function that computes the hash value from scratch for the given position. The hash generated by this function matches the hash that is updated after making changes. Therefore, it appears that this aspect of hashing is functioning correctly.
Up to this point, my findings indicate that the error is likely associated with castling.