Subversion Repositories Games.Chess Giants

Rev

Rev 33 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 33 Rev 108
Line 84... Line 84...
84
      return PawnAttacks(side, source);
84
      return PawnAttacks(side, source);
85
    case king:
85
    case king:
86
      return KingAttacks(source);
86
      return KingAttacks(source);
87
  }
87
  }
88
  return 0;
88
  return 0;
-
 
89
}
-
 
90
 
-
 
91
/* last modified 01/07/14 */
-
 
92
/*
-
 
93
 *******************************************************************************
-
 
94
 *                                                                             *
-
 
95
 *   Attacked() is used to determine if <square> is attacked.  It returns a    *
-
 
96
 *   two bit value, 01 if <square> is attacked by <side>, 10 if <square> is    *
-
 
97
 *   attacked by <enemy> and 11 if <square> is attacked by both sides.         *
-
 
98
 *                                                                             *
-
 
99
 *******************************************************************************
-
 
100
 */
-
 
101
uint64_t Attacked(TREE * RESTRICT tree, int side, uint64_t squares) {
-
 
102
  uint64_t bsliders, rsliders, set;
-
 
103
  int square;
-
 
104
 
-
 
105
  bsliders = Bishops(side) | Queens(side);
-
 
106
  rsliders = Rooks(side) | Queens(side);
-
 
107
  for (set = squares; set; set &= set - 1) {
-
 
108
    square = LSB(set);
-
 
109
    do {
-
 
110
      if (KingAttacks(square) & Kings(side))
-
 
111
        break;
-
 
112
      if (KnightAttacks(square) & Knights(side))
-
 
113
        break;
-
 
114
      if (bishop_attacks[square] & bsliders &&
-
 
115
          BishopAttacks(square, OccupiedSquares) & bsliders)
-
 
116
        break;
-
 
117
      if (rook_attacks[square] & rsliders &&
-
 
118
          RookAttacks(square, OccupiedSquares) & rsliders)
-
 
119
        break;
-
 
120
      Clear(square, squares);
-
 
121
    } while (0);
-
 
122
  }
-
 
123
  return squares;
89
}
124
}