The Zobrist hash function used in Polyglot does not keep track of which rook has castling rights if there are multiple rooks present on the same side of the king.
Positions in which a rook has castling rights which is not an outer rook (closest to a or h file) should not be included in the book.
The declaration of RANDOM_CASTLE is replaced by:
const uint64 RandomCastle[16]={ < to be filled in > }
In this case “castle” will be the exclusive or of entries taken from RANDOM_CASTLE, one for each rook that has castling rights (so at most four offsets).
The offset for a rook that has castling rights is computed as:
0 | If the rook is white and on the king side. |
1 | If the rook is white and on the queen side. |
2 | If the rook is black and on the king side. |
3 | If the rook is black and on the queen side. |
This is like in ordinary chess.
3+file | If the rook is white. |
9+file | If the rook is black. |
A castling move is encoded as a usual move (see above) in which the “from square” is the position of the king and the “to square” is the position of the rook.