DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Polyglot Zobrist Key Generator  (Read 14,491 times)

shinkarom

  • Member
  • Joined in 2014
  • **
  • Posts: 14
    • Participated in NANY Challenge Four Times
Polyglot Zobrist Key Generator
« on: November 24, 2019, 08:56 AM »
https://shinkarom.github.io/zobrist/
When writing a chess engine, you might want to support opening books in Polyglot bin format. This format creates the hash for the position using Zobrist hashing. If you want to debug your hash generator, I haven't found any services that can generate hash from the position.
So I wrote one. You paste the position as FEN and get the resulting hash.

TaoPhoenix

  • 0 - 60 ... then back to 0 again!
  • Supporting Member
  • Joined in 2011
  • **
  • Posts: 4,642
    • Participated in NANY Challenge Three Times
Re: Polyglot Zobrist Key Generator
« Reply #1 on: February 08, 2020, 09:24 PM »

Wow, this is beyond my level to use, but I'm psyched to see a Chess Nany Entry!

I did a PGN processor and got mouser's permission because it was custom commissioned and not shared elsewhere.

Some notes for the DC Crowd:

- FEN stands for "Forsyth Edwards Notation", which is a text way to describe a position in chess. The basic idea is line by line, it contains data like "Rook, 2 spaces Queen 2 spaces King / Next Line" and some notes like whose move it is and whether things like castling or en passant are legal.

- An "Opening book" means a chess program first looks for known positions in its "book" or library, to see what might be a good move to try, rather than trying to figure it out from scratch. The basic idea is that for a set position, "there's a severe risk the computer won't understand to do x or y as good choices, but instead plays move Q which leads to a bad or even losing position".  So I think I understand this Nany to add misc positions themselves into the book. So I think the Caro Kann opening has some famous endgame, and you could put that in there, so even if it didn't have twenty hours of work with the full move set to get there, suddenly if the computer spots that the specific position showed up, "oh, I should do this here".

Neat!
Use attachthumb=# to show an attached image as an expandable thumbnail, or attach=# to show full size. (With Brackets)

shinkarom

  • Member
  • Joined in 2014
  • **
  • Posts: 14
    • Participated in NANY Challenge Four Times
Re: Polyglot Zobrist Key Generator
« Reply #2 on: February 09, 2020, 11:48 AM »
My intended use is much simpler.
When you're writing an engine, most opening books are in the Polyglot format (.bin). The positions in the book are encoded with Zobrist hashing (https://www.chessprogramming.org/Zobrist_Hashing). So to check if the position is present in the book, you first need to hash it. And because Murphy's law states that "it's bug-ridden and broken from the start", you need to debug your hashing somehow, ideally comparing with some other generator.
I couldn't find anything to debug my hashing while writing Mussaurus (http://www.talkchess.com/forum3/viewtopic.php?f=2&t=72372), so I wrote my own generator.

Original address: https://www.donationcoder.com/forum/index.php?topic=49103.0