From 06fa323c65999ce6859bec3e27fa40ca04c17aa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Benencia?= Date: Fri, 27 Mar 2015 12:16:56 -0300 Subject: correctly print a board --- lib/print.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'lib') 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"); + } -- cgit v1.2.3