diff options
author | Raúl Benencia <rul@kalgan.cc> | 2015-03-27 12:16:56 -0300 |
---|---|---|
committer | Raúl Benencia <rul@kalgan.cc> | 2015-03-27 12:16:56 -0300 |
commit | 06fa323c65999ce6859bec3e27fa40ca04c17aa5 (patch) | |
tree | 6d34450bc0e138b435b4c772362a807deb552c3d | |
parent | 4730d415e980cfe1fbf385deaaf2d2f9c531e1fc (diff) |
correctly print a boardboard
-rw-r--r-- | include/print.h | 2 | ||||
-rw-r--r-- | lib/print.c | 24 |
2 files changed, 15 insertions, 11 deletions
diff --git a/include/print.h b/include/print.h index bc2f9df..c17459f 100644 --- a/include/print.h +++ b/include/print.h @@ -5,6 +5,6 @@ void print_piece(Piece); void print_square(Square); -void print_board(Board*); +void print_board(Board); #endif diff --git a/lib/print.c b/lib/print.c index 431641e..249e486 100644 --- a/lib/print.c +++ b/lib/print.c @@ -10,8 +10,6 @@ void print_piece(Piece p) { } void print_square(Square s) { - puts("+-+\n|"); - if (s.piece == NULL) switch (s.color) { case WHITE: @@ -26,20 +24,26 @@ void print_square(Square s) { } else print_piece(*s.piece); - - puts("|\n+-+"); - - return; } -void print_board(Board *b) { +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++) { - print_square(*b[i][j]); + printf("| "); + print_square(b[i][j]); + putchar(' '); } - - putchar('\n'); + printf("|\n"); } + + for (j = 0; j < SIZE; j++) + printf("+---"); + printf("+\n"); + } |