
-----------------------------------
5ilentAK
Sat Dec 15, 2012 11:23 pm

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)




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 = 193 and x = 193 and x = 127 and x = 122 and x = 124 and x = 51 and x = 53 and x = 51 and x = 302 and y >= 193 and x = 193 and x = 193 and x = 127 and x = 122 and x = 124 and x = 51 and x = 53 and x = 51 and x = 302 and y >= 193 and x = 193 and x = 193 and x = 127 and x = 122 and x = 124 and x = 51 and x = 53 and x = 51 and x 