X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=src%2Fttt-board.c;h=dd068b5850285110f84e5436f2fa99c960b2910d;hb=95898262b4ce4a2a3d36f70a4e6cc8188decc142;hp=9e9db9889394a5b719aa1cba68a8b92abf66ec30;hpb=cce891bb05118330ca609ac989491ad8a2fa7f71;p=ttt diff --git a/src/ttt-board.c b/src/ttt-board.c index 9e9db98..dd068b5 100644 --- a/src/ttt-board.c +++ b/src/ttt-board.c @@ -25,7 +25,11 @@ void ttt_board_init (ttt_board_t *board) { - /* XXX: NYI */ + int i; + for (i = 0; i < TTT_BOARD_MAX_CELLS; i++) + { + board->cells[i] = TTT_CELL_EMPTY; + } } /* Initialize a board from its string representation. @@ -50,7 +54,15 @@ ttt_board_init_from_string (ttt_board_t *board, char * ttt_board_to_string (ttt_board_t *board) { - /* XXX: NYI */ + char *s; + xasprintf (&s, "\r\n" + "%c|%c|%c\r\n" + "%c|%c|%c\r\n" + "%c|%c|%c", + board->cells[0], board->cells[1], board->cells[2], + board->cells[3], board->cells[4], board->cells[5], + board->cells[6], board->cells[7], board->cells[8]); + return s; } /* Write a string representation of a board to the provided file.