- case AMBIGUITY_NONE:
- break;
-
- case AMBIGUITY_FILE:
- str += file_to_char(square_file(from));
- break;
-
- case AMBIGUITY_RANK:
- str += rank_to_char(square_rank(from));
- break;
-
- case AMBIGUITY_BOTH:
- str += square_to_string(from);
- break;
-
- default:
- assert(false);
+ if (m == MOVE_NONE)
+ return "(none)";
+ else if (m == MOVE_NULL)
+ return "(null)";
+ else if (move_is_long_castle(m))
+ san = "O-O-O";
+ else if (move_is_short_castle(m))
+ san = "O-O";
+ else
+ {
+ Piece pc = pos.piece_on(move_from(m));
+ if (type_of_piece(pc) != PAWN)
+ {
+ san += piece_type_to_char(type_of_piece(pc), true);
+ Square from = move_from(m);
+ switch (move_ambiguity(pos, m)) {
+ case AMBIGUITY_NONE:
+ break;
+ case AMBIGUITY_FILE:
+ san += file_to_char(square_file(from));
+ break;
+ case AMBIGUITY_RANK:
+ san += rank_to_char(square_rank(from));
+ break;
+ case AMBIGUITY_BOTH:
+ san += square_to_string(from);
+ break;
+ default:
+ assert(false);
+ }
+ }
+ if (pos.move_is_capture(m))
+ {
+ if (type_of_piece(pc) == PAWN)
+ san += file_to_char(square_file(move_from(m)));
+ san += "x";
+ }
+ san += square_to_string(move_to(m));
+ if (move_promotion(m))
+ {
+ san += '=';
+ san += piece_type_to_char(move_promotion(m), true);