Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Turing Tic Tac Toe Help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
5ilentAK




PostPosted: Sat Dec 15, 2012 11:23 pm   Post subject: Turing Tic Tac Toe Help

What is it you are trying to achieve?
Creating a Tic Tac Toe Game


What is the problem you are having?
Do not know how to repeat the code once someone won. The program is supposed to exit once a player has won 3 times or after each round. Also the user may quit the program after every round. I do not know how to implement these codes into my program.

Describe what you have tried to solve this problem
I tried pasting the whole code into the if statements at the end and it's not working.

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


var character : string(1)
var player1, player2, first : string
var numberOfWins1, numberOfWins2: int
var x, y : int
var mark : array 1 .. 3, 1 .. 3 of int
var midx, midy, counter, win, z : int := 0
numberOfWins1 := 0
numberOfWins2 := 0


put "Welcome to..."
put ""

put "******** ","*******  ", "******* ", " ******** ", "******* ", "******* ", "******** ", "******** ", "********"
put "   *    ", "    *     ", "*       ", "    *     ", "*     * ", "*       ", "    *    ","*      * ", "*       "
put "   *    ", "    *     ", "*       ", "    *     ", "*     * ", "*       ", "    *    ","*      * ", "*       "
put "   *    ", "    *     ", "*       ", "    *     ", "******* ", "*       ", "    *    ","*      * ", "********"
put "   *    ", "    *     ", "*       ", "    *     ", "*     * ", "*       ", "    *    ","*      * ", "*       "
put "   *    ", "    *     ", "*       ", "    *    ", " *     * ", "*       ", "    *    ", "*      * ","*       "
put "   *    ", " *******  ", "******* ", "    *    ", " *     * ", "******* ", "    *    ", "******** ","********"
put "==============================================================================="
put "Objective: "
put "The goal of Tic Tac Toe is to be the first player to get three in a row on a 3x3"
put "grid, or four in a row in a 4x4 grid."
put ""

put "Instructions: "
put "1. Players alternate placing Xs and Os on the board until either (a) one player"
put "has three in a row, horizontally, vertically or diagonally; or (b) all nine"
put "squares are filled."
put "2. If a player is able to draw three Xs or three Os in a row, that player wins."
put "3. If all nine squares are filled and neither player has three in a row, the"
put "game is a draw."
put "4. First player up to 3 wins, wins the game, however you will be asked to stop"
put "after each round"
put ""
put "Press any key to continue.."
getch(character)

cls
delay (100)
put "******** ","*******  ", "******* ", " ******** ", "******* ", "******* ", "******** ", "******** ", "********"
put "   *    ", "    *     ", "*       ", "    *     ", "*     * ", "*       ", "    *    ","*      * ", "*       "
put "   *    ", "    *     ", "*       ", "    *     ", "*     * ", "*       ", "    *    ","*      * ", "*       "
put "   *    ", "    *     ", "*       ", "    *     ", "******* ", "*       ", "    *    ","*      * ", "********"
put "   *    ", "    *     ", "*       ", "    *     ", "*     * ", "*       ", "    *    ","*      * ", "*       "
put "   *    ", "    *     ", "*       ", "    *    ", " *     * ", "*       ", "    *    ", "*      * ","*       "
put "   *    ", " *******  ", "******* ", "    *    ", " *     * ", "******* ", "    *    ", "******** ","********"
put "==============================================================================="
put ""
put "Please input the name of player 1: "..
get player1:*
put "Please input the name of player 2: "..
get player2:*
put ""

cls
delay (100)

put "******** ","*******  ", "******* ", " ******** ", "******* ", "******* ", "******** ", "******** ", "********"
put "   *    ", "    *     ", "*       ", "    *     ", "*     * ", "*       ", "    *    ","*      * ", "*       "
put "   *    ", "    *     ", "*       ", "    *     ", "*     * ", "*       ", "    *    ","*      * ", "*       "
put "   *    ", "    *     ", "*       ", "    *     ", "******* ", "*       ", "    *    ","*      * ", "********"
put "   *    ", "    *     ", "*       ", "    *     ", "*     * ", "*       ", "    *    ","*      * ", "*       "
put "   *    ", "    *     ", "*       ", "    *    ", " *     * ", "*       ", "    *    ", "*      * ","*       "
put "   *    ", " *******  ", "******* ", "    *    ", " *     * ", "******* ", "    *    ", "******** ","********"
put "==============================================================================="
put "Number Of Wins"
put "--------------"
put player1, ": ", numberOfWins1
put player2, ": ", numberOfWins2
first:= player1

proc choice
    counter += 1
    if counter mod 2 = 0 then
        drawoval (midx, midy, 20, 20, black)
    elsif counter mod 2 = 1 then
        drawline (midx - 25, midy - 25, midx + 25, midy + 25, black)
        drawline (midx - 25, midy + 25, midx + 25, midy - 25, black)
    end if
end choice
for a : 1 .. 3
    for b : 1 .. 3
        mark (a, b) := 0
    end for
end for

loop

Draw.ThickLine (500, 250, 500, 50, 3, 12)
Draw.ThickLine (400, 250, 400, 50, 3, 12)
Draw.ThickLine (300, 120, 600, 120, 3, 12)
Draw.ThickLine (300, 190, 600, 190, 3, 12)

 loop
        Mouse.Where (x, y, z)
        if x >= 302 and y >= 193 and x <= 396 and y <= 249 and z=1 and mark (1, 1) = 0 then
        midx := 349
        midy := 221
        choice
        if counter mod 2 = 0 then
                mark (1, 1) := 2
            elsif counter mod 2 = 1 then
                mark (1, 1) := 1
            end if
        elsif x >= 404 and y >= 193 and x <= 497 and y <= 249 and z=1 and mark (1, 2) = 0 then
        midx := 451
        midy := 221
        choice
        if counter mod 2 = 0 then
                mark (1, 2) := 2
            elsif counter mod 2 = 1 then
                mark (1, 2) := 1
            end if       
        elsif x >= 504 and y >= 193 and x <= 598 and y <= 249 and z=1 and mark (1, 3) = 0 then
        midx := 551
        midy := 221
        choice
        if counter mod 2 = 0 then
                mark (1, 3) := 2
            elsif counter mod 2 = 1 then
                mark (1, 3) := 1
            end if
        elsif x >= 302 and y >= 127 and x <= 396 and y <= 188 and z=1 and mark (2, 1) = 0 then
        midx := 349
        midy := 158
        choice
        if counter mod 2 = 0 then
                mark (2, 1) := 2
            elsif counter mod 2 = 1 then
                mark (2, 1) := 1
            end if   
        elsif x >= 402 and y >= 122 and x <= 498 and y <= 188 and z=1 and mark (2, 2) = 0 then
        midx := 450
        midy := 155
        choice
        if counter mod 2 = 0 then
                mark (2, 2) := 2
            elsif counter mod 2 = 1 then
                mark (2, 2) := 1
            end if   
        elsif x >= 504 and y >= 124 and x <= 598 and y <= 186 and z=1 and mark (2, 3) = 0 then
        midx := 551
        midy := 155
        choice
        if counter mod 2 = 0 then
                mark (2, 3) := 2
            elsif counter mod 2 = 1 then
                mark (2, 3) := 1
            end if   
        elsif x >= 302 and y >= 51 and x <= 396 and y <= 116 and z=1 and mark (3, 1) = 0 then
        midx := 349
        midy := 84
        choice
        if counter mod 2 = 0 then
                mark (3, 1) := 2
            elsif counter mod 2 = 1 then
                mark (3, 1) := 1
            end if
        elsif x >= 404 and y >= 53 and x <= 497 and y <= 116 and z=1 and mark (3, 2) = 0  then
        midx := 451
        midy := 84
        choice
        if counter mod 2 = 0 then
                mark (3, 2) := 2
            elsif counter mod 2 = 1 then
                mark (3, 2) := 1
            end if   
        elsif x >= 504 and y >= 51 and x <= 598 and y <= 114 and z=1 and mark (3, 3) = 0 then
        midx := 551
        midy := 84
        choice
        if counter mod 2 = 0 then
                mark (3, 3) := 2
            elsif counter mod 2 = 1 then
                mark (3, 3) := 1
            end if   
end if
 if mark (1, 1) = mark (1, 2) and mark (1, 2) = mark (1, 3) and mark (1, 2) not= 0 then
            win := mark (1, 1)
        elsif mark (2, 1) = mark (2, 2) and mark (2, 2) = mark (2, 3) and mark (2, 2) not= 0 then
            win := mark (2, 1)
        elsif mark (3, 1) = mark (3, 2) and mark (3, 2) = mark (3, 3) and mark (3, 2) not= 0 then
            win := mark (3, 1)
        elsif mark (1, 1) = mark (2, 1) and mark (2, 1) = mark (3, 1) and mark (2, 1) not= 0 then
            win := mark (1, 1)
        elsif mark (1, 2) = mark (2, 2) and mark (2, 2) = mark (3, 2) and mark (2, 2) not= 0 then
            win := mark (1, 2)
        elsif mark (1, 3) = mark (2, 3) and mark (2, 3) = mark (3, 3) and mark (2, 3) not= 0 then
            win := mark (1, 3)
        elsif mark (1, 1) = mark (2, 2) and mark (2, 2) = mark (3, 3) and mark (2, 2) not= 0 then
            win := mark (1, 1)
        elsif mark (1, 3) = mark (2, 2) and mark (2, 2) = mark (3, 1) and mark (2, 2) not= 0 then
            win := mark (1, 3)
        end if
        delay (90)
        exit when win not= 0
        exit when counter = 9
    end loop
 loop
        if counter = 9 then
           put "tied"
        elsif win = 1 and first = player2 then
           put player2, " won!"
           numberOfWins2 := numberOfWins2 +1
        elsif win = 1 and first = player1 then
            put player1, " won!"
           numberOfWins1 := numberOfWins1 +1
        elsif win = 2 and first = player2 then
            put player2, " won!"
           numberOfWins2 := numberOfWins2 +1
        elsif win = 2 and first = player1 then
            put player1, " won!"
           numberOfWins1 := numberOfWins1 +1
        end if
     


end loop
end loop




Please specify what version of Turing you are using
Version 4.1.1
Sponsor
Sponsor
Sponsor
sponsor
5ilentAK




PostPosted: Sun Dec 16, 2012 5:12 pm   Post subject: RE:Turing Tic Tac Toe Help

Please i need help :s
Panphobia




PostPosted: Sun Dec 16, 2012 5:19 pm   Post subject: RE:Turing Tic Tac Toe Help

put it in a procedure and call it three times?
5ilentAK




PostPosted: Sun Dec 16, 2012 5:43 pm   Post subject: Re: RE:Turing Tic Tac Toe Help

Panphobia @ Sun Dec 16, 2012 5:19 pm wrote:
put it in a procedure and call it three times?


can you help me write a code for it?
Panphobia




PostPosted: Sun Dec 16, 2012 5:47 pm   Post subject: RE:Turing Tic Tac Toe Help

since it is best of 3 right, just make a procedure with the code you want to repeat three times, then check for wins, and losses and make an if, like if wins = 1 and lose = 1 then call the procedure once more, else if wins = 2 then..... you see what im getting at there, and for the procedure just read about it on the wiki on compsci http://wiki.compsci.ca/index.php?title=Turing_Functions_and_Procedures
5ilentAK




PostPosted: Sun Dec 16, 2012 6:09 pm   Post subject: Re: RE:Turing Tic Tac Toe Help

Can you implement that into my program? I've been trying and i can't seem to get it to work Sad
Panphobia




PostPosted: Sun Dec 16, 2012 6:11 pm   Post subject: RE:Turing Tic Tac Toe Help

Show me what you have done already, I wont do all the work for you
5ilentAK




PostPosted: Sun Dec 16, 2012 6:21 pm   Post subject: Re: Turing Tic Tac Toe Help

It's kind of rough, and a new program, i tried putting the proc "playAgain" whether the person has tied or won or lost. It doesn't repeat itself though

var character : string(1)
var player1, player2, first : string
var numberOfWins1, numberOfWins2: int
var x, y : int
var command : string
var mark : array 1 .. 3, 1 .. 3 of int
var midx, midy, counter, win, z : int := 0
numberOfWins1 := 0
numberOfWins2 := 0
player1 := "1"
player2 := "2"
first := player1
put "Number Of Wins"
put "--------------"
put player1, ": ", numberOfWins1
put player2, ": ", numberOfWins2
proc choice
counter += 1
if counter mod 2 = 0 then
drawoval (midx, midy, 20, 20, black)
elsif counter mod 2 = 1 then
drawline (midx - 25, midy - 25, midx + 25, midy + 25, black)
drawline (midx - 25, midy + 25, midx + 25, midy - 25, black)
end if
end choice
for a : 1 .. 3
for b : 1 .. 3
mark (a, b) := 0
end for
end for
procedure playAgain ( n : int )
for i : 1 .. n
Draw.ThickLine (500, 250, 500, 50, 3, 12)
Draw.ThickLine (400, 250, 400, 50, 3, 12)
Draw.ThickLine (300, 120, 600, 120, 3, 12)
Draw.ThickLine (300, 190, 600, 190, 3, 12)


loop
Mouse.Where (x, y, z)
if x >= 302 and y >= 193 and x <= 396 and y <= 249 and z=1 and mark (1, 1) = 0 then
midx := 349
midy := 221
choice
if counter mod 2 = 0 then
mark (1, 1) := 2
elsif counter mod 2 = 1 then
mark (1, 1) := 1
end if
elsif x >= 404 and y >= 193 and x <= 497 and y <= 249 and z=1 and mark (1, 2) = 0 then
midx := 451
midy := 221
choice
if counter mod 2 = 0 then
mark (1, 2) := 2
elsif counter mod 2 = 1 then
mark (1, 2) := 1
end if
elsif x >= 504 and y >= 193 and x <= 598 and y <= 249 and z=1 and mark (1, 3) = 0 then
midx := 551
midy := 221
choice
if counter mod 2 = 0 then
mark (1, 3) := 2
elsif counter mod 2 = 1 then
mark (1, 3) := 1
end if
elsif x >= 302 and y >= 127 and x <= 396 and y <= 188 and z=1 and mark (2, 1) = 0 then
midx := 349
midy := 158
choice
if counter mod 2 = 0 then
mark (2, 1) := 2
elsif counter mod 2 = 1 then
mark (2, 1) := 1
end if
elsif x >= 402 and y >= 122 and x <= 498 and y <= 188 and z=1 and mark (2, 2) = 0 then
midx := 450
midy := 155
choice
if counter mod 2 = 0 then
mark (2, 2) := 2
elsif counter mod 2 = 1 then
mark (2, 2) := 1
end if
elsif x >= 504 and y >= 124 and x <= 598 and y <= 186 and z=1 and mark (2, 3) = 0 then
midx := 551
midy := 155
choice
if counter mod 2 = 0 then
mark (2, 3) := 2
elsif counter mod 2 = 1 then
mark (2, 3) := 1
end if
elsif x >= 302 and y >= 51 and x <= 396 and y <= 116 and z=1 and mark (3, 1) = 0 then
midx := 349
midy := 84
choice
if counter mod 2 = 0 then
mark (3, 1) := 2
elsif counter mod 2 = 1 then
mark (3, 1) := 1
end if
elsif x >= 404 and y >= 53 and x <= 497 and y <= 116 and z=1 and mark (3, 2) = 0 then
midx := 451
midy := 84
choice
if counter mod 2 = 0 then
mark (3, 2) := 2
elsif counter mod 2 = 1 then
mark (3, 2) := 1
end if
elsif x >= 504 and y >= 51 and x <= 598 and y <= 114 and z=1 and mark (3, 3) = 0 then
midx := 551
midy := 84
choice
if counter mod 2 = 0 then
mark (3, 3) := 2
elsif counter mod 2 = 1 then
mark (3, 3) := 1
end if
end if
if mark (1, 1) = mark (1, 2) and mark (1, 2) = mark (1, 3) and mark (1, 2) not= 0 then
win := mark (1, 1)
elsif mark (2, 1) = mark (2, 2) and mark (2, 2) = mark (2, 3) and mark (2, 2) not= 0 then
win := mark (2, 1)
elsif mark (3, 1) = mark (3, 2) and mark (3, 2) = mark (3, 3) and mark (3, 2) not= 0 then
win := mark (3, 1)
elsif mark (1, 1) = mark (2, 1) and mark (2, 1) = mark (3, 1) and mark (2, 1) not= 0 then
win := mark (1, 1)
elsif mark (1, 2) = mark (2, 2) and mark (2, 2) = mark (3, 2) and mark (2, 2) not= 0 then
win := mark (1, 2)
elsif mark (1, 3) = mark (2, 3) and mark (2, 3) = mark (3, 3) and mark (2, 3) not= 0 then
win := mark (1, 3)
elsif mark (1, 1) = mark (2, 2) and mark (2, 2) = mark (3, 3) and mark (2, 2) not= 0 then
win := mark (1, 1)
elsif mark (1, 3) = mark (2, 2) and mark (2, 2) = mark (3, 1) and mark (2, 2) not= 0 then
win := mark (1, 3)
end if
delay (90)
exit when win not= 0
exit when counter = 9
end loop
end for
end playAgain

playAgain (1)
loop
if mark (1, 1) = mark (1, 2) and mark (1, 2) = mark (1, 3) and mark (1, 2) not= 0 then
win := mark (1, 1)
elsif mark (2, 1) = mark (2, 2) and mark (2, 2) = mark (2, 3) and mark (2, 2) not= 0 then
win := mark (2, 1)
elsif mark (3, 1) = mark (3, 2) and mark (3, 2) = mark (3, 3) and mark (3, 2) not= 0 then
win := mark (3, 1)
elsif mark (1, 1) = mark (2, 1) and mark (2, 1) = mark (3, 1) and mark (2, 1) not= 0 then
win := mark (1, 1)
elsif mark (1, 2) = mark (2, 2) and mark (2, 2) = mark (3, 2) and mark (2, 2) not= 0 then
win := mark (1, 2)
elsif mark (1, 3) = mark (2, 3) and mark (2, 3) = mark (3, 3) and mark (2, 3) not= 0 then
win := mark (1, 3)
elsif mark (1, 1) = mark (2, 2) and mark (2, 2) = mark (3, 3) and mark (2, 2) not= 0 then
win := mark (1, 1)
elsif mark (1, 3) = mark (2, 2) and mark (2, 2) = mark (3, 1) and mark (2, 2) not= 0 then
win := mark (1, 3)
end if
delay (90)
exit when win not= 0
exit when counter = 9
end loop

if counter = 9 then
put "tied"
put "Do you want to play again?"
get command
if command = "yes" then
playAgain(1)
end if
elsif win = 1 and first = player2 then
put player2, " won!"
numberOfWins2 := numberOfWins2 +1
put "Do you want to play again?"
get command
if command = "yes" then
playAgain(1)
end if
elsif win = 1 and first = player1 then
put player1, " won!"
numberOfWins1 := numberOfWins1 +1
put "Do you want to play again?"
get command
if command = "yes" then
playAgain(1)
end if
elsif win = 2 and first = player2 then
put player2, " won!"
numberOfWins2 := numberOfWins2 +1
put "Do you want to play again?"
get command
if command = "yes" then
playAgain(1)
end if
elsif win = 2 and first = player1 then
put player1, " won!"
numberOfWins1 := numberOfWins1 +1
put "Do you want to play again?"
get command
if command = "yes" then
playAgain(1)
end if
end if
Sponsor
Sponsor
Sponsor
sponsor
Panphobia




PostPosted: Sun Dec 16, 2012 6:25 pm   Post subject: RE:Turing Tic Tac Toe Help

can you use code brackets, and please can you make your code cleaner, commenting maybe? Also make an algorithm that decides the winner, not just using one giant if. But I will see what the problem is
5ilentAK




PostPosted: Sun Dec 16, 2012 6:33 pm   Post subject: Re: Turing Tic Tac Toe Help

Turing:


var character : string(1)
var player1, player2, first : string
var numberOfWins1, numberOfWins2: int
var x, y : int
var command : string
var mark : array 1 .. 3, 1 .. 3 of int
var midx, midy, counter, win, z : int := 0

numberOfWins1 := 0
numberOfWins2 := 0
player1 := "1"
player2 := "2"
first := player1


put "Number Of Wins"
put "--------------"
put player1, ": ", numberOfWins1
put player2, ": ", numberOfWins2
proc choice
    counter += 1
    if counter mod 2 = 0 then
        drawoval (midx, midy, 20, 20, black)                                      %draws the circle
    elsif counter mod 2 = 1 then
        drawline (midx - 25, midy - 25, midx + 25, midy + 25, black)
        drawline (midx - 25, midy + 25, midx + 25, midy - 25, black)              %draws the x
    end if 
end choice
for a : 1 .. 3
    for b : 1 .. 3
        mark (a, b) := 0
    end for
end for
procedure playAgain (  n : int )
            for i : 1 .. n
Draw.ThickLine (500, 250, 500, 50, 3, 12)                                          %draws the playing table
Draw.ThickLine (400, 250, 400, 50, 3, 12)
Draw.ThickLine (300, 120, 600, 120, 3, 12)
Draw.ThickLine (300, 190, 600, 190, 3, 12)


 loop
        Mouse.Where (x, y, z)
        if x >= 302 and y >= 193 and x <= 396 and y <= 249 and z=1 and mark (1, 1) = 0 then       %all the points of the playing table
        midx := 349
        midy := 221
        choice
        if counter mod 2 = 0 then
                mark (1, 1) := 2
            elsif counter mod 2 = 1 then
                mark (1, 1) := 1
            end if
        elsif x >= 404 and y >= 193 and x <= 497 and y <= 249 and z=1 and mark (1, 2) = 0 then
        midx := 451
        midy := 221
        choice
        if counter mod 2 = 0 then
                mark (1, 2) := 2
            elsif counter mod 2 = 1 then
                mark (1, 2) := 1
            end if       
        elsif x >= 504 and y >= 193 and x <= 598 and y <= 249 and z=1 and mark (1, 3) = 0 then
        midx := 551
        midy := 221
        choice
        if counter mod 2 = 0 then
                mark (1, 3) := 2
            elsif counter mod 2 = 1 then
                mark (1, 3) := 1
            end if
        elsif x >= 302 and y >= 127 and x <= 396 and y <= 188 and z=1 and mark (2, 1) = 0 then
        midx := 349
        midy := 158
        choice
        if counter mod 2 = 0 then
                mark (2, 1) := 2
            elsif counter mod 2 = 1 then
                mark (2, 1) := 1
            end if   
        elsif x >= 402 and y >= 122 and x <= 498 and y <= 188 and z=1 and mark (2, 2) = 0 then
        midx := 450
        midy := 155
        choice
        if counter mod 2 = 0 then
                mark (2, 2) := 2
            elsif counter mod 2 = 1 then
                mark (2, 2) := 1
            end if   
        elsif x >= 504 and y >= 124 and x <= 598 and y <= 186 and z=1 and mark (2, 3) = 0 then
        midx := 551
        midy := 155
        choice
        if counter mod 2 = 0 then
                mark (2, 3) := 2
            elsif counter mod 2 = 1 then
                mark (2, 3) := 1
            end if   
        elsif x >= 302 and y >= 51 and x <= 396 and y <= 116 and z=1 and mark (3, 1) = 0 then
        midx := 349
        midy := 84
        choice
        if counter mod 2 = 0 then
                mark (3, 1) := 2
            elsif counter mod 2 = 1 then
                mark (3, 1) := 1
            end if
        elsif x >= 404 and y >= 53 and x <= 497 and y <= 116 and z=1 and mark (3, 2) = 0  then
        midx := 451
        midy := 84
        choice
        if counter mod 2 = 0 then
                mark (3, 2) := 2
            elsif counter mod 2 = 1 then
                mark (3, 2) := 1
            end if   
        elsif x >= 504 and y >= 51 and x <= 598 and y <= 114 and z=1 and mark (3, 3) = 0 then
        midx := 551
        midy := 84
        choice
        if counter mod 2 = 0 then
                mark (3, 3) := 2
            elsif counter mod 2 = 1 then
                mark (3, 3) := 1
            end if   
end if
 if mark (1, 1) = mark (1, 2) and mark (1, 2) = mark (1, 3) and mark (1, 2) not= 0 then                      %determines the winner
            win := mark (1, 1)
        elsif mark (2, 1) = mark (2, 2) and mark (2, 2) = mark (2, 3) and mark (2, 2) not= 0 then
            win := mark (2, 1)
        elsif mark (3, 1) = mark (3, 2) and mark (3, 2) = mark (3, 3) and mark (3, 2) not= 0 then
            win := mark (3, 1)
        elsif mark (1, 1) = mark (2, 1) and mark (2, 1) = mark (3, 1) and mark (2, 1) not= 0 then
            win := mark (1, 1)
        elsif mark (1, 2) = mark (2, 2) and mark (2, 2) = mark (3, 2) and mark (2, 2) not= 0 then
            win := mark (1, 2)
        elsif mark (1, 3) = mark (2, 3) and mark (2, 3) = mark (3, 3) and mark (2, 3) not= 0 then
            win := mark (1, 3)
        elsif mark (1, 1) = mark (2, 2) and mark (2, 2) = mark (3, 3) and mark (2, 2) not= 0 then
            win := mark (1, 1)
        elsif mark (1, 3) = mark (2, 2) and mark (2, 2) = mark (3, 1) and mark (2, 2) not= 0 then
            win := mark (1, 3)
        end if
        delay (90)
        exit when win not= 0
        exit when counter = 9
    end loop
            end for
        end playAgain
       
playAgain (1)
loop
 if mark (1, 1) = mark (1, 2) and mark (1, 2) = mark (1, 3) and mark (1, 2) not= 0 then
            win := mark (1, 1)
        elsif mark (2, 1) = mark (2, 2) and mark (2, 2) = mark (2, 3) and mark (2, 2) not= 0 then
            win := mark (2, 1)
        elsif mark (3, 1) = mark (3, 2) and mark (3, 2) = mark (3, 3) and mark (3, 2) not= 0 then
            win := mark (3, 1)
        elsif mark (1, 1) = mark (2, 1) and mark (2, 1) = mark (3, 1) and mark (2, 1) not= 0 then
            win := mark (1, 1)
        elsif mark (1, 2) = mark (2, 2) and mark (2, 2) = mark (3, 2) and mark (2, 2) not= 0 then
            win := mark (1, 2)
        elsif mark (1, 3) = mark (2, 3) and mark (2, 3) = mark (3, 3) and mark (2, 3) not= 0 then
            win := mark (1, 3)
        elsif mark (1, 1) = mark (2, 2) and mark (2, 2) = mark (3, 3) and mark (2, 2) not= 0 then
            win := mark (1, 1)
        elsif mark (1, 3) = mark (2, 2) and mark (2, 2) = mark (3, 1) and mark (2, 2) not= 0 then
            win := mark (1, 3)
        end if
        delay (90)
        exit when win not= 0
        exit when counter = 9
        end loop
       
if counter = 9 then
           put "tied"
           put "Do you want to play again?"
           get command
           if command = "yes" then
           playAgain(1)
           end if
        elsif win = 1 and first = player2 then
           put player2, " won!"
           numberOfWins2 := numberOfWins2 +1
           put "Do you want to play again?"
           get command
           if command = "yes" then
           playAgain(1)
           end if
        elsif win = 1 and first = player1 then
            put player1, " won!"
           numberOfWins1 := numberOfWins1 +1
           put "Do you want to play again?"
           get command
           if command = "yes" then
           playAgain(1)
           end if
        elsif win = 2 and first = player2 then
            put player2, " won!"
           numberOfWins2 := numberOfWins2 +1
           put "Do you want to play again?"
           get command
           if command = "yes" then
           playAgain(1)
           end if
        elsif win = 2 and first = player1 then
            put player1, " won!"
           numberOfWins1 := numberOfWins1 +1
           put "Do you want to play again?"
           get command
           if command = "yes" then
           playAgain(1)
           end if
        end if



Panphobia




PostPosted: Sun Dec 16, 2012 6:45 pm   Post subject: RE:Turing Tic Tac Toe Help

I would suggest cleaning up your code, so it is more readable, adding comments like I said, and maybe suggest scrapping some of it, so it is easier for you to understand why it is not giving you the option to play again, but it is calling the procedure, check out why when you say yes it is finishing your programs execution, i made a put statement in your procedure and it does output it, so your problem is not that it isnt being executed
5ilentAK




PostPosted: Sun Dec 16, 2012 7:08 pm   Post subject: RE:Turing Tic Tac Toe Help

I noticed that the proc does execute, but i still don't see how it's not allowing me to play it again Sad
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 12 Posts ]
Jump to:   


Style:  
Search: