1 /* board.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 // board.h
23 
24 #ifndef BOARD_H
25 #define BOARD_H
26 
27 // includes
28 
29 #include "colour.h"
30 #include "square.h"
31 #include "util.h"
32 
33 namespace adapter {
34 
35 // constants
36 
37 const int Empty = 0;
38 
39 const int SideH = 0;
40 const int SideA = 1;
41 const int SideNb = 2;
42 
43 // types
44 
45 struct board_t {
46 
47    uint8 square[SquareNb];
48    sint8 pos[SquareNb];
49 
50    uint8 list[ColourNb][32];
51    sint8 list_size[ColourNb];
52 
53    sint8 number[12];
54 
55    sint8 turn;
56    uint8 castle[ColourNb][SideNb];
57    uint8 ep_square;
58 
59    sint16 ply_nb;
60    sint16 move_nb;
61 
62    uint64 key;
63 };
64 
65 // functions
66 
67 extern bool board_is_ok        (const board_t * board);
68 
69 extern void board_clear        (board_t * board);
70 extern void board_start        (board_t * board);
71 
72 extern void board_copy         (board_t * dst, const board_t * src);
73 extern bool board_equal        (const board_t * board_1, const board_t * board_2);
74 
75 extern void board_init_list    (board_t * board);
76 
77 extern int  board_flags        (const board_t * board);
78 
79 extern bool board_can_play     (const board_t * board);
80 extern int  board_mobility     (const board_t * board);
81 
82 extern bool board_is_check     (const board_t * board);
83 extern bool board_is_mate      (const board_t * board);
84 extern bool board_is_stalemate (const board_t * board);
85 
86 extern int  king_pos           (const board_t * board, int colour);
87 
88 extern void board_disp         (const board_t * board);
89 
90 }  // namespace adapter
91 
92 #endif // !defined BOARD_H
93 
94 // end of board.h
95 
96