X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fsan.cpp;h=d8d051d8a69a4de2c9d142822ff0237c952bec49;hb=5c81602d14539f8259a715477315e28b5de7cb54;hp=5d5fc06c811924aeb5a7a4f2e0a37c8042cff2ac;hpb=8f59de48f559e477dc383d5b51a0b842986758d0;p=stockfish diff --git a/src/san.cpp b/src/san.cpp index 5d5fc06c..d8d051d8 100644 --- a/src/san.cpp +++ b/src/san.cpp @@ -1,7 +1,7 @@ /* Stockfish, a UCI chess playing engine derived from Glaurung 2.1 Copyright (C) 2004-2008 Tord Romstad (Glaurung author) - Copyright (C) 2008 Marco Costalba + Copyright (C) 2008-2009 Marco Costalba Stockfish is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -70,23 +70,28 @@ const std::string move_to_san(const Position& pos, Move m) { assert(pos.is_ok()); assert(move_is_ok(m)); + Square from, to; + PieceType pt; + + from = move_from(m); + to = move_to(m); + pt = type_of_piece(pos.piece_on(move_from(m))); + std::string san = ""; if (m == MOVE_NONE) return "(none)"; else if (m == MOVE_NULL) return "(null)"; - else if (move_is_long_castle(m)) + else if (move_is_long_castle(m) || (int(to - from) == -2 && pt == KING)) san = "O-O-O"; - else if (move_is_short_castle(m)) + else if (move_is_short_castle(m) || (int(to - from) == 2 && pt == KING)) san = "O-O"; else { - Piece pc = pos.piece_on(move_from(m)); - if (type_of_piece(pc) != PAWN) + if (pt != PAWN) { - san += piece_type_to_char(type_of_piece(pc), true); - Square from = move_from(m); + san += piece_type_to_char(pt, true); switch (move_ambiguity(pos, m)) { case AMBIGUITY_NONE: break; @@ -105,7 +110,7 @@ const std::string move_to_san(const Position& pos, Move m) { } if (pos.move_is_capture(m)) { - if (type_of_piece(pc) == PAWN) + if (pt == PAWN) san += file_to_char(square_file(move_from(m))); san += "x"; }