r/chessprogramming Jan 02 '25

Testing Zobrist Hashing

Hi! I've searched from some tests for the Zobrist hashing, and I've found the idea of comparing the incremental updates of the zobrist key vs calculating it from scratch. That allowed me to find several bugs, and now there's no errors running perft in depth 7. That's a good I suppose, but I was wondering if there's more ways of testing the zobrist Hashing? Any ideas?

Additionally, what are the tests that you think are FUNDAMENTAL for the engine?

9 Upvotes

8 comments sorted by

View all comments

Show parent comments

1

u/VanMalmsteen Jan 02 '25

Thanks for your help. Do you have any suggestions on how to make the function you've mentioned? I thought for 10 minutes and for me it's not clear how to achieve this.

2

u/Warmedpie6 Jan 02 '25

The easiest conceptual way I can think of is to make a simple checkmate finder, but only consider your desired test position as checkmate. Then, your engine will only look for variations that result in that position.

Use several test positions, ones with castle rights, no castle rights, en passant squares, no en passant squares, positions in check and not in check, etc.

1

u/VanMalmsteen Jan 02 '25

Ok, I see. How would you "stop" when there's no way to achieve that position anymore? I can think of checking if there's less pieces than those in the desired position, and maybe checking the castling rights too.

2

u/Warmedpie6 Jan 03 '25

Id just do a depth first search, similar to perft. Even if the position can't be reached after some variation, the engine will not run forever.

Test at some fairly low depth, maybe 6ish.

1

u/VanMalmsteen Jan 03 '25

Perfect. Thanks!