Updated the ttt-gui.cpp
This commit is contained in:
@ -29,9 +29,11 @@ bool playerWon(string character) {
|
|||||||
|
|
||||||
void generateOpponent() {
|
void generateOpponent() {
|
||||||
if (playerWon("X") || playerWon("O")) return;
|
if (playerWon("X") || playerWon("O")) return;
|
||||||
int random = rand() % 10;
|
srand(time(0));
|
||||||
|
int random = rand() % 9;
|
||||||
|
|
||||||
if (rows[random] != "-") {
|
if (rows[random] != "-") {
|
||||||
|
SDL_Delay(100);
|
||||||
generateOpponent();
|
generateOpponent();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -126,7 +128,7 @@ int main() {
|
|||||||
if (rows[pos-1] == "-") {
|
if (rows[pos-1] == "-") {
|
||||||
rows[pos-1] = "X";
|
rows[pos-1] = "X";
|
||||||
render(renderer, background);
|
render(renderer, background);
|
||||||
SDL_Delay(500);
|
SDL_Delay(300);
|
||||||
generateOpponent();
|
generateOpponent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user