First draft attempt at ttt_board_is_won
authorKevin Worth <kevin@theworths.org>
Tue, 13 Dec 2005 22:38:58 +0000 (22:38 +0000)
committerKevin Worth <kevin@theworths.org>
Tue, 13 Dec 2005 22:38:58 +0000 (22:38 +0000)
src/test-board.c

index 13f6f6c2af3017b757a649ad2db659ca7b1cd793..9e7f90e8ea4daf01beec034d3b4425b9fb5b578f 100644 (file)
@@ -2,6 +2,26 @@
 
 #include "ttt-board.h"
 
+int ttt_board_is_won (ttt_board_t *board);
+
+int ttt_board_is_won (ttt_board_t *board)
+{
+    if (
+       board->cells[0] == board->cells[3] && board->cells[3] == board->cells[6] ||
+       board->cells[7] == board->cells[4] && board->cells[4] == board->cells[7] ||
+       board->cells[2] == board->cells[5] && board->cells[5] == board->cells[8] ||
+       board->cells[0] == board->cells[1] && board->cells[1] == board->cells[2] ||
+       board->cells[3] == board->cells[4] && board->cells[4] == board->cells[5] ||
+       board->cells[6] == board->cells[7] && board->cells[7] == board->cells[8] ||
+       board->cells[0] == board->cells[4] && board->cells[4] == board->cells[8] ||
+       board->cells[2] == board->cells[4] && board->cells[4] == board->cells[6] ||
+       )
+/*     printf ("'board->current_player''s Win!") */
+       return(1);
+    else
+       return(0);
+}
+
 int
 main (void)
 {
@@ -17,8 +37,10 @@ main (void)
        printf ("\"\n");    
 
        printf ("Make a move \n");
-       m = getchar() - '0';
+       m = getchar();
        newline = getchar();
+       printf ("getchar returned a numeric value of %d which is character '%c'\n", m, m);
+       m = m - '0';
        ttt_board_make_move (&board, m);
     }