lots
[arrocco.git] / check.c
blobcf850a8df38f0786ac67f4698396f90fe9807e7e
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, * child;
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] | pos->pieces[11 ^ side]))
22 return 1;
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)
30 return 1;
34 return 0;
37 Int64 inCheckFromPawn(Position * pos, int side){
38 return 0;
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;