1 /* Copyright (C) 2007-2011 Vincent Ollivier
3 * Purple Haze is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * Purple Haze is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 PieceType
Move::promotion_type() const
26 case KNIGHT_PROMOTION
:
27 case KNIGHT_PROMOTION_CAPTURE
:
29 case BISHOP_PROMOTION
:
30 case BISHOP_PROMOTION_CAPTURE
:
33 case ROOK_PROMOTION_CAPTURE
:
36 case QUEEN_PROMOTION_CAPTURE
:
43 PieceType
Move::castle_side() const
46 case KING_CASTLE
: return KING
;
47 case QUEEN_CASTLE
: return QUEEN
;
48 default: return EMPTY
;
52 std::ostream
& operator<<(std::ostream
& out
, const Move move
)
54 return (out
<< move
.to_string());
57 std::string
Move::to_string() const
59 if (is_null()) return "#";
61 res
+= static_cast<char>('a' + orig_file());
62 res
+= static_cast<char>('1' + orig_rank());
63 res
+= static_cast<char>('a' + dest_file());
64 res
+= static_cast<char>('1' + dest_rank());
66 res
+= Piece(BLACK
, promotion_type()).to_string(); // Lower case