user21801: I previously asked how to use polyglot in c# with a chess engine. My question then was not accurate. What I want to know is, what property(ies) of the bin file object I need to do the following:
I will parse a FEN string, then, I will access a property of this bin file that will allow me to generate a FEN string that's hopefully linked to a move, whether this move is in a pgn string of a game, or saved as a specific data struct. 
Then I will compare my parsed string with such FEN string obtained by accessing a property of the bin file object.
Then, when I find a match, I will use another method to obtain the next immediate move, which is the one the computer should do, according to the game from which the move was obtained after finding a FEN matching the one I parsed in the first place.
So, I guess a pseudo code would look like:
 string extractedMove;
 string parsedFEN = "...";
 object bookBytes = File.Read(pathofthebookfile);

  string GetFENOutOfBook (string FENvalue)
{ 
   return  bookBytes.Find(FENproperty/Fenkey => FENvalue);
}

  public void GetMove ()
{
   extractedMove = bookBytes.moves[GetFENOutOfBook(parsedFEN)].ToString();
}

So can someone point me in the right direction to do this? I just need to know what properties I need to work with of the polyglot book bin file so I can create the logic to extract the move. Thanks in advance!

user25669: The binary file consists of a number of 16 byte entries, formatted as follows first 8 bytes the position hash, next 2 bytes encode the move as mentioned in the previous post, the next 2 are the move weights and the final 4 are the move learning.
The main problem you'll have is matching the position hash you generate with that used in  the book, so you'll need to use the same keys as in the polyglot source code to match up, or generate the book yourself with your own keys.

user825: I have every reason to believe your approach is wrong and will lead to disaster. I'm saying it as someone who make softwares to work on Polyglot books (www.smallchess.com).
You are strongly advised NOT to do all the hard works like what I did before. Just wrap the C++ Polyglot code in your C#! Your time should be on your C# engine, not this.
Polyglot, although open source is not something you would like to port to C# unless you are super motivated. Why? Polyglot has bunch of hash keys. Screenshot on my source code:

There was never any good documentation on Polyglot, it existed mainly in source code. Today, not many people really know how that does (including myself). I understand only part of it, by reading source code.
That was the comment I wrote to myself when I started using Polyglot many years ago:
    /*
     * A PolyGlot book move is encoded as follows:
     *
     * bit  0- 5: destination square (from 0 to 63)
     * bit  6-11: origin square (from 0 to 63)
     * bit 12-13-14: promotion piece (from KNIGHT == 1 to QUEEN == 4)
     *
     * Castling moves follow "king captures rook" representation. So in case
     * book move is a promotion we have to convert to our representation, in
     * all other cases we can directly compare with a Move after having
     * masked out special Move's flags that are not supported by PolyGlot.
     */

Polyglot works like this:

Given a position, convert to a hash key. I have my screenshot for the conversion



Use the key to locate an entry in the book using binary search
Read the entry from (2)
Extract the chess move like:



21801: <p>I previously asked how to use polyglot in c# with a chess engine. My question then was not accurate. What I want to know is, what property(ies) of the bin file object I need to do the following:</p>

<p>I will parse a FEN string, then, I will access a property of this bin file that will allow me to generate a FEN string that's hopefully linked to a move, whether this move is in a pgn string of a game, or saved as a specific data struct. </p>

<p>Then I will compare my parsed string with such FEN string obtained by accessing a property of the bin file object.</p>

<p>Then, when I find a match, I will use another method to obtain the next immediate move, which is the one the computer should do, according to the game from which the move was obtained after finding a FEN matching the one I parsed in the first place.</p>

<p>So, I guess a pseudo code would look like:</p>

<pre><code> string extractedMove;
 string parsedFEN = "...";
 object bookBytes = File.Read(pathofthebookfile);

  string GetFENOutOfBook (string FENvalue)
{ 
   return  bookBytes.Find(FENproperty/Fenkey =&gt; FENvalue);
}

  public void GetMove ()
{
   extractedMove = bookBytes.moves[GetFENOutOfBook(parsedFEN)].ToString();
}
</code></pre>

<p>So can someone point me in the right direction to do this? I just need to know what properties I need to work with of the polyglot book bin file so I can create the logic to extract the move. Thanks in advance!</p>
 25669: <p>The binary file consists of a number of 16 byte entries, formatted as follows first 8 bytes the position hash, next 2 bytes encode the move as mentioned in the previous post, the next 2 are the move weights and the final 4 are the move learning.
The main problem you'll have is matching the position hash you generate with that used in  the book, so you'll need to use the same keys as in the polyglot source code to match up, or generate the book yourself with your own keys.</p>
 825: <p>I have every reason to believe your approach is wrong and will lead to disaster. I'm saying it as someone who make softwares to work on Polyglot books (www.smallchess.com).</p>

<p>You are <strong>strongly</strong> advised <strong>NOT</strong> to do all the hard works like what I did before. Just wrap the C++ Polyglot code in your C#! Your time should be on your C# engine, not this.</p>

<p>Polyglot, although open source is not something you would like to port to C# unless you are super motivated. Why? Polyglot has bunch of hash keys. Screenshot on my source code:</p>

<p><a href="https://i.stack.imgur.com/11hKh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/11hKh.png" alt="enter image description here"></a></p>

<p>There was never any good documentation on Polyglot, it existed mainly in source code. Today, not many people really know how that does (including myself). I understand only part of it, by reading source code.</p>

<p>That was the comment I wrote to myself when I started using Polyglot many years ago:</p>

<pre><code>    /*
     * A PolyGlot book move is encoded as follows:
     *
     * bit  0- 5: destination square (from 0 to 63)
     * bit  6-11: origin square (from 0 to 63)
     * bit 12-13-14: promotion piece (from KNIGHT == 1 to QUEEN == 4)
     *
     * Castling moves follow "king captures rook" representation. So in case
     * book move is a promotion we have to convert to our representation, in
     * all other cases we can directly compare with a Move after having
     * masked out special Move's flags that are not supported by PolyGlot.
     */
</code></pre>

<p>Polyglot works like this:</p>

<ol>
<li>Given a position, convert to a hash key. I have my screenshot for the conversion</li>
</ol>

<p><a href="https://i.stack.imgur.com/DT1YO.png" rel="noreferrer"><img src="https://i.stack.imgur.com/DT1YO.png" alt="enter image description here"></a></p>

<ol start="2">
<li>Use the key to locate an entry in the book using binary search</li>
<li>Read the entry from (2)</li>
<li>Extract the chess move like:</li>
</ol>

<p><a href="https://i.stack.imgur.com/nMsmp.png" rel="noreferrer"><img src="https://i.stack.imgur.com/nMsmp.png" alt="enter image description here"></a></p>
