Chess - Programming - Polyglot Book Format - Castle

Castle is part of the Key

It is the exclusive or of entries from the RANDOM_CASTLE sub-array.

The offsets are computed as:

ColorCastle SideOffset
WhiteKing-side Castle0
WhiteQueen-side Castle1
BlackKing-side Castle2
BlackQueen-side Castle3

NOTE: These flags are all true in the starting position and are only updated after the appropriate King, Rook or Castling moves.

  • The default value for this field should be 0 if if none of these flags apply; i.e. then castle=0.

WARNING: Even though the flag may indicate that castleling can be done, a program should verify that a Castle-move is actually valid, as some mistakes may creep in.