-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathio.c
45 lines (43 loc) · 1.59 KB
/
io.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "io.h"
void printBitboard(const U64 bb) {
printf("\n");
for (int rank = 0; rank < 8; ++ rank) {
printf("%d ", 8 - rank);
for (int file = 0; file < 8; ++ file) {
int square = 8 * rank + file;
printf(" %d ", get_bit(bb, square) ? 1 : 0);
}
printf("\n");
}
printf("\n a b c d e f g h\n\n");
printf("ULL bb = %llu \n", bb);
}
void print_board() {
printf("\n");
for (int rank = 0; rank < 8; ++ rank) {
for (int file = 0; file < 8; ++ file) {
int square = rank * 8 + file;
if (! file) printf("%d ", 8 - rank);
int piece = -1;
for (int bb_piece = P; bb_piece <= k; ++ bb_piece) {
if (get_bit(bitboards[bb_piece], square)) {
piece = bb_piece;
}
}
#ifdef WIN64
printf(" %c ", (piece == -1) ? '.' : ascii_pieces[piece]);
#else // WIN64
printf(" %s", (piece == -1) ? ". " : unicode_pieces[piece]);
#endif // WIN64
}
printf("\n");
}
printf("\n a b c d e f g h\n");
printf(" Side to play : %s.\n", ! side ? "white" : "black");
printf(" En passant : %s.\n", (enpassant != no_sq) ?
index2coord[enpassant] : "no");
printf(" Castling : %c%c%c%c\n\n", (castle & wckc) ? 'K' : '-',
(castle & wcqc) ? 'Q' : '-',
(castle & bckc) ? 'k' : '-',
(castle & bcqc) ? 'q' : '-');
}