// castling move in in
// right update binary decimal
// king & rooks didn't move: 1111 & 1111 = 1111 15
// white king moved: 1111 & 1100 = 1100 12
// white king's rook moved: 1111 & 1110 = 1110 14
// white queen's rook moved: 1111 & 1101 = 1101 13
//
// black king moved: 1111 & 0011 = 1011 3
// black king's rook moved: 1111 & 1011 = 1011 11
// black queen's rook moved: 1111 & 0111 = 0111 7
// zig fmt: off
const CASTLING_RIGHTS: [64]CastligType = .{
7, 15, 15, 15, 3, 15, 15, 11,
15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15,
13, 15, 15, 15, 12, 15, 15, 14
};
// zig fmt: on
fn update(self: *@This(), square: Square) void {
var ret = @bitCast(CastligType, self.*);
ret &= CASTLING_RIGHTS[@enumToInt(square)];
self.* = @bitCast(Castling, ret);
}