2 Glaurung, a UCI chess playing engine.
3 Copyright (C) 2004-2008 Tord Romstad
5 Glaurung is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 Glaurung is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #if !defined(MOVE_H_INCLUDED)
21 #define MOVE_H_INCLUDED
57 inline Square move_from(Move m) {
58 return Square((int(m) >> 6) & 077);
61 inline Square move_to(Move m) {
62 return Square(m & 077);
65 inline PieceType move_promotion(Move m) {
66 return PieceType((int(m) >> 12) & 7);
69 inline bool move_is_ep(Move m) {
70 return bool((int(m) >> 15) & 1);
73 inline bool move_is_castle(Move m) {
74 return bool((int(m) >> 16) & 1);
77 inline bool move_is_short_castle(Move m) {
78 return move_is_castle(m) && (move_to(m) > move_from(m));
81 inline bool move_is_long_castle(Move m) {
82 return move_is_castle(m) && (move_to(m) < move_from(m));
85 inline Move make_promotion_move(Square from, Square to, PieceType promotion) {
86 return Move(int(to) | (int(from) << 6) | (int(promotion) << 12));
89 inline Move make_move(Square from, Square to) {
90 return Move(int(to) | (int(from) << 6));
93 inline Move make_castle_move(Square from, Square to) {
94 return Move(int(to) | (int(from) << 6) | (1 << 16));
97 inline Move make_ep_move(Square from, Square to) {
98 return Move(int(to) | (int(from) << 6) | (1 << 15));
106 extern std::ostream &operator << (std::ostream &os, Move m);
107 extern Move move_from_string(const Position &pos, const std::string &str);
108 extern const std::string move_to_string(Move m);
109 extern bool move_is_ok(Move m);
112 #endif // !defined(MOVE_H_INCLUDED)