89_TicTacToe2 in perl

This commit is contained in:
RibTips
2022-01-07 02:58:35 -05:00
committed by GitHub
parent 6dda7ce25a
commit 8c8a00df0f
+3
View File
@@ -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;;