Sundries
[arrocco.git] / check.c
blob74f5184696b093062be392cc042ee7afbfa3c715
1 // check.c
2 // 26 Aug 2007
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;
15 Int64 occupancy[4];
16 int i;
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])
22 return 1;
24 return 0;
27 Int64 inCheckFromPawn(Position * pos, int side){
28 return 0;
31 Int64 areKingsAdjacent(Position * pos){
32 Int64 wkingSquare = lowestBit(pos->pieces[12]);
33 return kingFields[wkingSquare] & pos->pieces[13];
36 int inCheck(Position * pos, int side){
37 return (inCheckFromKnight(pos, side) || inCheckFromSlider(pos, side)
38 || inCheckFromPawn(pos, side) || areKingsAdjacent(pos)) != 0ULL;