1 /***************************************************************************
2 check.cpp - description
4 begin : Mon Sep 19 2005
5 copyright : (C) 2005 by Maurizio Monge
6 email : monge@linuz.sns.it
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
22 Board::mat_add(uint8_t piece
, uint8_t piece_pos
)
24 int p
= PIECE_TO_12(piece
);
25 int c
= mat_tracking
[ p
].count
;
27 ASSERT(c
>=0 && c
<=11 && p
<12 && p
>=0);
29 mat_tracking
[ p
].pos
[ mat_tracking
[ p
].count
++ ] = piece_pos
;
30 mat_idx
[ piece_pos
] = c
;
34 Board::mat_remove(uint8_t piece
, uint8_t piece_pos
)
36 int p
= PIECE_TO_12(piece
);
37 int c
= mat_tracking
[ p
].count
;
38 int idx
= mat_idx
[ piece_pos
];
40 ASSERT(c
>=0 && c
<=11 && p
<12 && p
>=0);
45 mat_tracking
[p
].pos
[idx
] = mat_tracking
[p
].pos
[c
];
46 mat_idx
[ mat_tracking
[p
].pos
[idx
] ] = idx
;
49 mat_tracking
[p
].count
= c
;
53 Board::mat_move(uint8_t piece
, uint8_t from
, uint8_t to
)
55 int p
= PIECE_TO_12(piece
);
56 int idx
= mat_idx
[ from
];
60 mat_tracking
[p
].pos
[idx
] = to
;
65 Board::recalc_mat_tracking()
68 mat_tracking
[j
].count
= 0;
77 if(data
[piece_pos
] && data
[piece_pos
]!=STONE
)
79 int p
= PIECE_TO_12(data
[piece_pos
]);
80 int c
= mat_tracking
[ p
].count
;
82 ASSERT(c
>=0 && c
<=11 && p
<12 && p
>=0);
84 mat_tracking
[ p
].pos
[ mat_tracking
[ p
].count
++ ] = piece_pos
;
85 mat_idx
[ piece_pos
] = c
;
92 Board::check_mat_tracking()
97 uint8_t p
= j
%6 + 1 + (j
/6 ? WHITE
: BLACK
);
98 for(int n
= 0;n
< mat_tracking
[ j
].count
; n
++)
100 ASSERT(!OUT_OF_BOARD(mat_tracking
[ j
].pos
[n
]));
101 ASSERT(data
[mat_tracking
[ j
].pos
[n
]] == p
);
104 tot
+= mat_tracking
[ j
].count
;
108 for(int i
=7;i
>=0;i
--)
111 for(int j
=7;j
>=0;j
--)