4 Int64
inCheckFromKnight(Position
* pos
, int side
){
5 int kingSquare
= lowestBit(pos
->pieces
[12 ^ side
]);
6 Int64 knightAttacks
= knightFields
[kingSquare
];
7 return knightAttacks
& pos
->pieces
[5 ^ side
];
10 Int64
inCheckFromSlider(Position
* pos
, int side
){
11 int kingSquare
= lowestBit(pos
->pieces
[12 ^ side
]);
12 Position children
[32];
13 Position
* endChildren
, * child
;
17 for (i
= 0; i
< 4; i
++)
18 occupancy
[i
] = pos
->white
[i
] | pos
->black
[i
];
20 Int64 rdests
= rookDestinations(pos
, kingSquare
, occupancy
);
21 if (rdests
& (pos
->pieces
[9 ^ side
] | pos
->pieces
[11 ^ side
]))
24 /* THIS IS WRONG... DO BISHOP MOVES RIGHT FIRST...
25 // now, for the bishops...
26 endChildren = bishopMoves(pos, kingSquare, children,
27 pos->white[pos->turn << 2], pos->white[(!pos->turn) << 2]);
28 for (child = children; child != endChildren; child++){
29 if (child->value[0] > 8000 || child->value[1] > 8000)
37 Int64
inCheckFromPawn(Position
* pos
, int side
){
41 Int64
areKingsAdjacent(Position
* pos
){
42 Int64 wkingSquare
= lowestBit(pos
->pieces
[12]);
43 return kingFields
[wkingSquare
] & pos
->pieces
[13];
46 int inCheck(Position
* pos
, int side
){
47 return (inCheckFromKnight(pos
, side
) || inCheckFromSlider(pos
, side
)
48 || inCheckFromPawn(pos
, side
) || areKingsAdjacent(pos
)) != 0ULL;