static bool opponent_has_positive_capture(const struct node *node) { const struct position *pos = node->pos; uint64_t attacks = pos->attack[opponent_pawn]; uint64_t victims = pos->map[0] & ~pos->map[pawn]; if (is_nonempty(attacks & victims)) return true; attacks |= pos->attack[opponent_knight]; attacks |= pos->attack[opponent_bishop]; victims &= ~pos->map[bishop]; victims &= ~pos->map[knight]; if (is_nonempty(attacks & victims)) return true; attacks |= pos->attack[opponent_rook]; victims = pos->map[queen]; if (is_nonempty(attacks & victims)) return true; attacks = pos->attack[opponent_king]; victims = pos->map[0] & ~pos->attack[0]; if (is_nonempty(attacks & victims)) return true; return false; }
static char* print_san_move_from(const struct position *pos, move m, char *str, enum player turn) { move moves[MOVE_ARRAY_LENGTH]; uint64_t ambig_pieces = UINT64_C(0); enum piece p = pos_piece_at(pos, mfrom(m)); (void) gen_moves(pos, moves); for (move *im = moves; *im != 0; ++im) { if ((mfrom(*im) != mfrom(m)) && (mto(*im) == mto(m)) && (pos_piece_at(pos, mfrom(*im)) == p)) ambig_pieces |= mfrom64(*im); } if ((p == pawn) && is_capture(m)) { *(str++) = index_to_file_ch(mfrom(m)); } else if (is_nonempty(ambig_pieces)) { if (is_nonempty(ambig_pieces & file64(mfrom(m)))) { if (is_nonempty(ambig_pieces & rank64(mfrom(m)))) { *(str++) = index_to_file_ch(mfrom(m)); } *(str++) = index_to_rank_ch(mfrom(m), turn); } else { *(str++) = index_to_file_ch(mfrom(m)); } } return str; }