From 8c8a00df0f94d5b7f1d3e315eef0381ce051af93 Mon Sep 17 00:00:00 2001 From: RibTips <36372030+ribtips@users.noreply.github.com> Date: Fri, 7 Jan 2022 02:58:35 -0500 Subject: [PATCH] 89_TicTacToe2 in perl --- 89_Tic-Tac-Toe/perl/tictactoe2.pl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/89_Tic-Tac-Toe/perl/tictactoe2.pl b/89_Tic-Tac-Toe/perl/tictactoe2.pl index 4bd12cf7..e7448e3e 100644 --- a/89_Tic-Tac-Toe/perl/tictactoe2.pl +++ b/89_Tic-Tac-Toe/perl/tictactoe2.pl @@ -67,6 +67,7 @@ sub main { print "IT'S A DRAW. THANK YOU.\n"; } +# This will check to see if anyone has won by adding up the various 3-in-a-row lines. sub check_for_winners { my %tally; foreach my $key (keys %winning_combos) { @@ -86,6 +87,8 @@ sub check_for_winners { } } +#On the computer's turn it will first check to see if it should block the player. If it finds it isn't going to win or need to block a player, the it will choose a spot to place it's X or O. + sub computer_choice { my $move; $move=&check_for_blocks_or_wins;;