2

I would like, if possible, for someone to provide a code snippet of a basic logic to access a Polyglot book file. I'm having trouble finding the file format documentation, so I don't know how to access it and use it in the code. I'm making a chess game and would like to use the books to support features in the game. If not too much trouble, I would rather have a c# code sample, since it's the language I'm fluent with right now.

  • It's not off-topic to ask on Chess SE about the documentation of a very chess-specific file format, is it? – Remellion Feb 2 at 8:52
3

Sorry, I don't have C# code. Can we do it in C++?

Polyglot book is defined like:

struct entry_t {
   uint64 key;
   uint16 move;
   uint16 count;
   uint16 n;
   uint16 sum;
};

You may want to wrap the C++ code inside your C#. How to do that is out of scope here.

| improve this answer | |
  • Thanks a lot for your reply! I understand that wrapping is out of scope. Well I'm learning C++, so this can be a good learn as you go exercise. So my plan is: import book file do method to find position on book (parsing moves string, comparing accessing boards list?) if found board similar to parsed position, create my own variant format to parse to my move manager so variant can be played out. – Jorge Acuna Feb 6 at 21:17
  • I didn't want to make my first comment too long, so here are a couple extra questions: So Polyglot file is just a collection of entry_t objects? I saw in your git link, you have a board class, so you then construct on your own reading the entry_t collection properties the board you need to find the variant? I thought in the book file you would have like a lot of positions defined as objects, so you can compare to them, am I wrong on this? Thanks for the help btw :)! – Jorge Acuna Feb 6 at 21:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.