blob: 249e4860aabbda0c0b0c5cda63d5a8ee79bf0846 (
plain)
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
46
47
48
49
|
#include <stdio.h>
#include <stdlib.h>
#include "print.h"
#include "piece.h"
/* Printing related functions */
void print_piece(Piece p) {
putchar(piece_character(p));
}
void print_square(Square s) {
if (s.piece == NULL)
switch (s.color) {
case WHITE:
putchar(' ');
break;;
case BLACK:
putchar('/');
break;
default:
perror("Wait... what?\n");
exit(EXIT_FAILURE);
}
else
print_piece(*s.piece);
}
void print_board(Board b) {
int i, j;
for (i = 0; i < SIZE; i++) {
for (j = 0; j < SIZE; j++)
printf("+---");
printf("+\n");
for (j = 0; j < SIZE; j++) {
printf("| ");
print_square(b[i][j]);
putchar(' ');
}
printf("|\n");
}
for (j = 0; j < SIZE; j++)
printf("+---");
printf("+\n");
}
|