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; }
static bool pmove_match(uint16_t polyglot_move, move m, bool flip) { if (flip) m = flip_m(m); if (pmfrom(polyglot_move) != mfrom(m) || pmto(polyglot_move) != mto(m)) return false; if (is_promotion(m)) return pmpromotion(polyglot_move) == mresultp(m); else return pmpromotion(polyglot_move) == 0; }
static char* print_san_move(const struct position *pos, move m, char *str, enum player turn) { int piece = pos_piece_at(pos, mfrom(m)); if (mtype(m) == mt_castle_kingside) return str + sprintf(str, "O-O"); else if (mtype(m) == mt_castle_queenside) return str + sprintf(str, "O-O-O"); if (piece != pawn) *str++ = (char)toupper((unsigned char)piece_to_char(piece)); str = print_san_move_from(pos, m, str, turn); if (is_capture(m)) *str++ = 'x'; str = index_to_str(str, mto(m), turn); if (mtype(m) == mt_en_passant) return str + sprintf(str, "e.p."); str = print_san_promotion(m, str); str = print_san_check(pos, m, str); *str = '\0'; return str; }
*str++ = 'x'; str = index_to_str(str, mto(m), turn); if (mtype(m) == mt_en_passant) return str + sprintf(str, "e.p."); str = print_san_promotion(m, str); str = print_san_check(pos, m, str); *str = '\0'; return str; } char* print_coor_move(move m, char str[static MOVE_STR_BUFFER_LENGTH], enum player turn) { str = index_to_str(str, mfrom(m), turn); str = index_to_str(str, mto(m), turn); if (is_promotion(m)) *str++ = tolower((unsigned char)piece_to_char(mresultp(m))); *str = '\0'; return str; } char* print_move(const struct position *pos, move m, char str[static MOVE_STR_BUFFER_LENGTH], enum move_notation_type t, enum player turn) { assert(is_move_valid(m)); assert(is_valid_piece(pos_piece_at(pos, mfrom(m))));