+{
+ if (move < 0 || move > 8)
+ return TTT_ERROR_NOT_GRID;
+
+ if (board->cells[move] != TTT_CELL_EMPTY)
+ return TTT_ERROR_NOT_VALID_MOVE;
+
+ board->cells[move] = board->current_player;
+
+ if (board->current_player == TTT_CELL_X)
+ board->current_player = TTT_CELL_O;
+ else
+ board->current_player = TTT_CELL_X;
+ return TTT_ERROR_NONE;
+}
+
+/* Checks to see if a player has won the game and should be called
+ * after every move.
+ *
+ * Returns: TTT_CELL_X if X's win. TTT_CELL_O if O's
+ * win. TTT_CELL_EMPTY if no win. The game can then check the value
+ * of the return and declare the winner.
+ */
+
+ttt_cell_t ttt_board_is_won (ttt_board_t *board)
+{
+ int i;
+
+ /* Loop over rows and columns looking for a win. */
+ for (i = 0; i < 3; i++)