From a2bcdf14be3ed35772809ecf7abe575e5473b979 Mon Sep 17 00:00:00 2001 From: RibTips <36372030+ribtips@users.noreply.github.com> Date: Fri, 7 Jan 2022 10:59:03 -0500 Subject: [PATCH] Fixed game termination bug Fixed issue where the game wouldn't terminate properly if the computer goes first. --- 89_Tic-Tac-Toe/perl/tictactoe2.pl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/89_Tic-Tac-Toe/perl/tictactoe2.pl b/89_Tic-Tac-Toe/perl/tictactoe2.pl index e7448e3e..0cbf4c10 100644 --- a/89_Tic-Tac-Toe/perl/tictactoe2.pl +++ b/89_Tic-Tac-Toe/perl/tictactoe2.pl @@ -58,6 +58,10 @@ sub main { $count++; &print_board; &check_for_winners; + if ($count >= 9) { + print "IT'S A DRAW. THANK YOU.\n"; + exit; + } &player_choice; $count++; &print_board; @@ -65,6 +69,7 @@ sub main { } } print "IT'S A DRAW. THANK YOU.\n"; + exit; } # This will check to see if anyone has won by adding up the various 3-in-a-row lines.