The castling position is held as 4 bytes in the move representation.
Castle flag 1111 which is 8 4 2 1.
int castleFlag = ((move >> 14) & 0x0F);
| Bytes | Decimal | Flags | How to query |
| 1000 | 8 | White King Side Castle | if(castleFlag & 8) |
| 0100 | 4 | White Queen Side Castle | if(castleFlag & 4) |
| 0010 | 2 | Black King Side Castle | if(castleFlag & 2) |
| 0001 | 1 | Black Queen Side Castle | if(castleFlag & 1) |

Leave a Reply