]> git.cworth.org Git - ttt/blob - src/test-board.c
dad0a5ed7af486042e58075fc6a76e242c39f245
[ttt] / src / test-board.c
1 /* Test ttt-board.c */
2
3 #include <stdio.h>                   
4 #include "ttt-board.h"
5
6 int ttt_board_make_move (ttt_board_t *board, int move);
7
8 int ttt_board_make_move (ttt_board_t *board, int move)
9 {                                    
10     
11     putchar(move);
12     if (board->cells[move] == '_')
13     {
14         board->cells[move] = 'X';
15         return(1);
16     }
17     else
18     {
19         return(0);
20     }
21 }
22                                   
23
24 int
25 main (void)
26 {
27     ttt_board_t board;
28     int m;
29     
30     ttt_board_init (&board);
31     
32     printf ("This is the board \"");
33     ttt_board_write (&board, stdout);
34     printf ("\"\n");
35     
36     printf ("Make a move");
37     m = getchar() - '0';
38     ttt_board_make_move (&board, m);
39
40     printf ("This is the board \"");
41     ttt_board_write (&board, stdout);
42     printf ("\"\n");
43
44     return 0;
45 }