Browse Source

added get computer input

remotes/origin/ticTacToe
Aimee Reincke 2 years ago
parent
commit
d95ca2b2e9
  1. 12
      src/c/ticTacToe.c
  2. 1
      src/c/ticTacToe.h

12
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;
}
}
}

1
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
Loading…
Cancel
Save