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.
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.