1 /* Copyright (C) 2007-2012 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/>.
28 Square positions
[2][7][9];
29 unsigned char nb_pieces
[2][7];
30 unsigned char total
[2];
37 std::fill(&positions
[0][0][0],
38 &positions
[0][0][0] + sizeof(positions
),
42 Square
position(Piece p
) const {
43 assert(0 <= p
.index() && p
.index() < 9);
44 return positions
[p
.color()][p
.type()][p
.index()];
46 Square
position(Color c
, PieceType t
, int i
) const {
47 assert(0 <= i
&& i
< 9);
48 return positions
[c
][t
][i
];
50 void set_position(Piece p
, Square s
) {
51 assert(0 <= p
.index() && p
.index() < 9);
52 positions
[p
.color()][p
.type()][p
.index()] = s
;
54 void set_position(Color c
, PieceType t
, int i
, Square s
) {
55 assert(0 <= i
&& i
< 9);
56 positions
[c
][t
][i
] = s
;
58 unsigned char count(Color c
, PieceType t
) const {
59 return nb_pieces
[c
][t
];
61 unsigned char count(Color c
) const {
65 // FIXME? No warning if nb < 0 or nb > 9
66 void inc_nb_pieces(Color c
, PieceType t
) {
70 void dec_nb_pieces(Color c
, PieceType t
) {
76 #endif /* !PIECESL_H */