diff --git a/src/c/ticTacToe.c b/src/c/ticTacToe.c index 402c591..915e796 100644 --- a/src/c/ticTacToe.c +++ b/src/c/ticTacToe.c @@ -20,6 +20,7 @@ void printField(char field[3][3]){ } printf("\n"); } + printf("/n"); } void initField(char field[3][3]) { @@ -864,3 +865,27 @@ void fillAlmostFull(char field[3][3], bool* pt) { } } } + +int play() { + printPrompt(); + int counter = 0; + char field[3][3]; + initField(field); + int winner = NOWINNERYET; + while (winner == NOWINNERYET) { + if (counter % 2 == 0) { + printField(field); + getPlayerInput(field); + winner = wasGameWon(field); + } + else if (counter % 2 == 1) { + printField(field); + getComputerInput(field); + winner = wasGameWon(field); + } + counter += 1; + } + printField(field); + printf("%d", winner); + return winner; +} \ No newline at end of file diff --git a/src/c/ticTacToe.h b/src/c/ticTacToe.h index 6db536c..007b9cb 100644 --- a/src/c/ticTacToe.h +++ b/src/c/ticTacToe.h @@ -17,5 +17,6 @@ bool validatePlayerInput(int row, int col); int wasGameWon(char field[3][3]); void getComputerInput(char field[3][3]); void fillAlmostFull(char field[3][3], bool *pt); +int play(); #endif \ No newline at end of file