sasunaruitalover
New member
Okay, so the code is too long, but heres the part thats not working:
#display game board
sub display_the_game_board {
clear_the_screen::clear();
#layout...
print " Tic Tac Toe\n\n\n";
print " 1 2 3\n\n";
print " | |\n";
print " A $a1 | $a2 | $a3\n";
print " | |\n";
print " ------|------|------\n";
print " | |\n";
print " B $b1 | $b2 | $b3\n";
print " | |\n";
print " ------|------|------\n";
print " | |\n";
print " C $c1 | $c2 | $c3\n";
print " | |\n\n\n";
print " $message\n\n" #to display status messgae....
}
when i try to run it it says that im concatenating on these lines. i know the symbol for that is . so i ddont know whats wrong with it.
that particualr code is called a few times,here:
sub play_the_game {
my $isfinished = 0; #subroutine loop controll
my $validmove = 0; #sees users moves...
my $reply = ""; # user command storage...
until ($isfinished) { #select a moce...
#player x won the game?
if ($winner eq "X") {
$xwins +=1; #number of times x won...
$message = "GAME OVER. Player x has won!"; #show winner... obviously...
&display_the_game_board(); #call sub to display the game board....
print "\n Press ENTER to continue: ";
$reply = <STDIN>; #pause so user can read the screen
return; # exit sub, game over!
}
#has o wwon the game?
if ($winner eq "O") {
$owins +=1; #number of time o won...
$message = "GAME OVER. Player o has won!"; #show winner... obviously...
&display_the_game_board(); #call sub to display the game board....
print "\n Press ENTER to continue: ";
$reply = <STDIN>; #pause so user can read the screen
return; # exit sub, game over!
}
#ties...
if ($winner eq "tie") {
$ties +=1;
$message = "GAME OVER! its a tie!"; #tie message....
&display_the_game_board(); #call sub to display the game board....
print "\n Press ENTER to continue: ";
$reply = <STDIN>; #pause so user can read the screen
return; # exit sub, game over!
}
#if were here, the game ISNT OVWER!
$message = "Player $player" , "'s moves"; #whos turn it is...
&display_the_game_board();
print "Select a square: ";
chomp($reply = <STDIN>);
#validate input and pass it the users input as an arg.
$validmove = &validate_selection($reply);
if ($validmove == 1) { #valid moves
my $nomove += 1; #count.... ## WAS WWRITTEN AS $NOMOVE = $NOMOVE +1!
&identify_selection($reply); #associates move with actual move on board...
} else { #say if invalid move...
clear_the_screen::clear();
print "INVALID MOVE! Press ENTER to try again. ";
$reply = <STDIN>;
}
if (my $nomove == 9) { #nine moves made wwith no decleration of winner....
$winner = "tie";
} else {
&look_for_winner();
}
#if last move was valid, switch turns.
if ($validmove == 1) {
if ($player eq "X") {
$player = "O";
} else {
$player = "X";
}
}
}#end loop.
}
and then thats it, i think.
I use strict and warnings... (if anyone wants to know...)
#display game board
sub display_the_game_board {
clear_the_screen::clear();
#layout...
print " Tic Tac Toe\n\n\n";
print " 1 2 3\n\n";
print " | |\n";
print " A $a1 | $a2 | $a3\n";
print " | |\n";
print " ------|------|------\n";
print " | |\n";
print " B $b1 | $b2 | $b3\n";
print " | |\n";
print " ------|------|------\n";
print " | |\n";
print " C $c1 | $c2 | $c3\n";
print " | |\n\n\n";
print " $message\n\n" #to display status messgae....
}
when i try to run it it says that im concatenating on these lines. i know the symbol for that is . so i ddont know whats wrong with it.
that particualr code is called a few times,here:
sub play_the_game {
my $isfinished = 0; #subroutine loop controll
my $validmove = 0; #sees users moves...
my $reply = ""; # user command storage...
until ($isfinished) { #select a moce...
#player x won the game?
if ($winner eq "X") {
$xwins +=1; #number of times x won...
$message = "GAME OVER. Player x has won!"; #show winner... obviously...
&display_the_game_board(); #call sub to display the game board....
print "\n Press ENTER to continue: ";
$reply = <STDIN>; #pause so user can read the screen
return; # exit sub, game over!
}
#has o wwon the game?
if ($winner eq "O") {
$owins +=1; #number of time o won...
$message = "GAME OVER. Player o has won!"; #show winner... obviously...
&display_the_game_board(); #call sub to display the game board....
print "\n Press ENTER to continue: ";
$reply = <STDIN>; #pause so user can read the screen
return; # exit sub, game over!
}
#ties...
if ($winner eq "tie") {
$ties +=1;
$message = "GAME OVER! its a tie!"; #tie message....
&display_the_game_board(); #call sub to display the game board....
print "\n Press ENTER to continue: ";
$reply = <STDIN>; #pause so user can read the screen
return; # exit sub, game over!
}
#if were here, the game ISNT OVWER!
$message = "Player $player" , "'s moves"; #whos turn it is...
&display_the_game_board();
print "Select a square: ";
chomp($reply = <STDIN>);
#validate input and pass it the users input as an arg.
$validmove = &validate_selection($reply);
if ($validmove == 1) { #valid moves
my $nomove += 1; #count.... ## WAS WWRITTEN AS $NOMOVE = $NOMOVE +1!
&identify_selection($reply); #associates move with actual move on board...
} else { #say if invalid move...
clear_the_screen::clear();
print "INVALID MOVE! Press ENTER to try again. ";
$reply = <STDIN>;
}
if (my $nomove == 9) { #nine moves made wwith no decleration of winner....
$winner = "tie";
} else {
&look_for_winner();
}
#if last move was valid, switch turns.
if ($validmove == 1) {
if ($player eq "X") {
$player = "O";
} else {
$player = "X";
}
}
}#end loop.
}
and then thats it, i think.
I use strict and warnings... (if anyone wants to know...)