Chess - Programming - Polyglot Book Format - Extensions for other forms of Chess - Chess960

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:

0If the rook is white and on the king side.
1If the rook is white and on the queen side.
2If the rook is black and on the king side.
3If the rook is black and on the queen side.

This is like in ordinary chess.

3+fileIf the rook is white.
9+fileIf the rook is black.

Encoding of moves

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.