diff --git a/src/c/ticTacToe.c b/src/c/ticTacToe.c index 7d2105f..3f3066a 100644 --- a/src/c/ticTacToe.c +++ b/src/c/ticTacToe.c @@ -138,3 +138,15 @@ int wasGameWon(char field[3][3]){ return winner; } +void getComputerInput(char field[3][3]){ + bool symbolSet = false; + while (!symbolSet){ + int row, col; + row = rand() % 3; + col = rand() % 3; + if (field[row][col] == '-'){ + field[row][col] = 'X'; + symbolSet = true; + } + } +} diff --git a/src/c/ticTacToe.h b/src/c/ticTacToe.h index ec68f18..222383d 100644 --- a/src/c/ticTacToe.h +++ b/src/c/ticTacToe.h @@ -15,5 +15,6 @@ void initField(char field[3][3]); void getPlayerInput(char field[3][3]); bool validatePlayerInput(int row, int col); int wasGameWon(char field[3][3]); +void getComputerInput(char field[3][3]); #endif \ No newline at end of file