force_inline static move *generate_rook_moves(uint64_t rooks, const uint64_t occupied, const uint64_t targets, move *moves) { int from; int to; uint64_t posmoves; while (rooks) { from = lsb(rooks); posmoves = rook_attacks(from, occupied) & targets; while (posmoves) { to = lsb(posmoves); *moves++ = MOVE(from, to); clear_lsb(posmoves); } clear_lsb(rooks); } return moves; }
BITBOARD attacks_to_square(struct board_t *brd,short sq) { BITBOARD bq,rq,kings; bq=brd->pcs[WHITE][BISHOP]|brd->pcs[WHITE][QUEEN]| brd->pcs[BLACK][BISHOP]|brd->pcs[BLACK][QUEEN]; rq=brd->pcs[WHITE][ROOK]|brd->pcs[WHITE][QUEEN]| brd->pcs[BLACK][ROOK]|brd->pcs[BLACK][QUEEN]; kings=setmask[brd->king[WHITE]]|setmask[brd->king[BLACK]]; return((pawn_attacks[WHITE][sq]&brd->pcs[BLACK][PAWN])| (pawn_attacks[BLACK][sq]&brd->pcs[WHITE][PAWN])| (knight_attacks[sq]&(brd->pcs[WHITE][KNIGHT]|brd->pcs[BLACK][KNIGHT]))| (bishop_attacks(brd,sq)&bq)| (rook_attacks(brd,sq)&rq)| (king_attacks[sq]&kings)); }