From 61b610de2fef17954d0b2b4ef4c38e972455c3c3 Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Mon, 23 Oct 2023 14:49:40 +0200 Subject: [PATCH] Updated the ttt-gui.cpp --- ttt-gui.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ttt-gui.cpp b/ttt-gui.cpp index 23a7f80..41565fd 100644 --- a/ttt-gui.cpp +++ b/ttt-gui.cpp @@ -29,9 +29,11 @@ bool playerWon(string character) { void generateOpponent() { if (playerWon("X") || playerWon("O")) return; - int random = rand() % 10; + srand(time(0)); + int random = rand() % 9; if (rows[random] != "-") { + SDL_Delay(100); generateOpponent(); return; } @@ -126,7 +128,7 @@ int main() { if (rows[pos-1] == "-") { rows[pos-1] = "X"; render(renderer, background); - SDL_Delay(500); + SDL_Delay(300); generateOpponent(); } }