1 /* piece.h
2 
3    GNU Chess protocol adapter
4 
5    Copyright (C) 2001-2011 Free Software Foundation, Inc.
6 
7    This program is free software: you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation, either version 3 of the License, or
10    (at your option) any later version.
11 
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16 
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 
22 // piece.h
23 
24 #ifndef PIECE_H
25 #define PIECE_H
26 
27 // includes
28 
29 #include "colour.h"
30 #include "util.h"
31 
32 namespace adapter {
33 
34 // constants
35 
36 const int BlackPawnFlag = 1 << 2;
37 const int WhitePawnFlag = 1 << 3;
38 const int KnightFlag    = 1 << 4;
39 const int BishopFlag    = 1 << 5;
40 const int RookFlag      = 1 << 6;
41 const int KingFlag      = 1 << 7;
42 
43 const int PawnFlags  = BlackPawnFlag | WhitePawnFlag;
44 const int QueenFlags = BishopFlag | RookFlag;
45 
46 const int PieceNone64 = 0;
47 const int BlackPawn64 = BlackPawnFlag;
48 const int WhitePawn64 = WhitePawnFlag;
49 const int Knight64    = KnightFlag;
50 const int Bishop64    = BishopFlag;
51 const int Rook64      = RookFlag;
52 const int Queen64     = QueenFlags;
53 const int King64      = KingFlag;
54 
55 const int PieceNone256   = 0;
56 const int BlackPawn256   = BlackPawn64 | Black;
57 const int WhitePawn256   = WhitePawn64 | White;
58 const int BlackKnight256 = Knight64    | Black;
59 const int WhiteKnight256 = Knight64    | White;
60 const int BlackBishop256 = Bishop64    | Black;
61 const int WhiteBishop256 = Bishop64    | White;
62 const int BlackRook256   = Rook64      | Black;
63 const int WhiteRook256   = Rook64      | White;
64 const int BlackQueen256  = Queen64     | Black;
65 const int WhiteQueen256  = Queen64     | White;
66 const int BlackKing256   = King64      | Black;
67 const int WhiteKing256   = King64      | White;
68 
69 const int BlackPawn12   =  0;
70 const int WhitePawn12   =  1;
71 const int BlackKnight12 =  2;
72 const int WhiteKnight12 =  3;
73 const int BlackBishop12 =  4;
74 const int WhiteBishop12 =  5;
75 const int BlackRook12   =  6;
76 const int WhiteRook12   =  7;
77 const int BlackQueen12  =  8;
78 const int WhiteQueen12  =  9;
79 const int BlackKing12   = 10;
80 const int WhiteKing12   = 11;
81 
82 // functions
83 
84 extern void piece_init      ();
85 
86 extern bool piece_is_ok     (int piece);
87 
88 extern int  piece_make_pawn (int colour);
89 extern int  piece_pawn_opp  (int piece);
90 
91 extern int  piece_colour    (int piece);
92 extern int  piece_type      (int piece);
93 
94 extern bool piece_is_pawn   (int piece);
95 extern bool piece_is_knight (int piece);
96 extern bool piece_is_bishop (int piece);
97 extern bool piece_is_rook   (int piece);
98 extern bool piece_is_queen  (int piece);
99 extern bool piece_is_king   (int piece);
100 
101 extern bool piece_is_slider (int piece);
102 
103 extern int  piece_to_12     (int piece);
104 extern int  piece_from_12   (int piece);
105 
106 extern int  piece_to_char   (int piece);
107 extern int  piece_from_char (int c);
108 
109 extern bool char_is_piece   (int c);
110 
111 }  // namespace adapter
112 
113 #endif // !defined PIECE_H
114 
115 // end of piece.h
116 
117