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