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)
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Banana




PostPosted: Thu Jan 10, 2013 10:11 am   Post subject: turing (tic tac toe)

What is it you are trying to achieve?
for the program to chose a winner in the tic tac toe game
What is the problem you are having?
i dont know how to command the prgramer to show a winner


Describe what you have tried to solve this problem
i have tried adding up the answers for it to equal a certain total



Turing:


setscreen ("graphics:max;max")
drawfillbox (0, 0, maxx, maxy, 3)
%All of the variables in the program
var HomePage : int := Pic.FileNew ("tictactoe.jpg")
var CenterX : int := round (maxx / 2) - round (Pic.Width (HomePage) / 2)
var CenterY : int := round (maxy / 2) - round (Pic.Height (HomePage) / 2)
var UserInp : char
var reply : string
var answer : string
var choice : string
var xpic : int := Pic.FileNew ("xpic.bmp")
var xpic2 : int := Pic.FileNew ("2xpic.bmp")
var xpic3 : int := Pic.FileNew ("3xpic.bmp")
var xpic4 : int := Pic.FileNew ("4xpic.bmp")
var xpic5 : int := Pic.FileNew ("5xpic.bmp")
var xpic6 : int := Pic.FileNew ("6xpic.bmp")
var xpic7 : int := Pic.FileNew ("7xpic.bmp")
var xpic8 : int := Pic.FileNew ("8xpic.bmp")
var xpic9 : int := Pic.FileNew ("9xpic.bmp")
var opic : int := Pic.FileNew ("opic.jpg")
var opic2 : int := Pic.FileNew ("2opic.jpg")
var opic3 : int := Pic.FileNew ("3opic.jpg")
var opic4 : int := Pic.FileNew ("4opic.jpg")
var opic5 : int := Pic.FileNew ("5opic.jpg")
var opic6 : int := Pic.FileNew ("6opic.jpg")
var opic7 : int := Pic.FileNew ("7opic.jpg")
var opic8 : int := Pic.FileNew ("8opic.jpg")
var opic9 : int := Pic.FileNew ("9opic.jpg")
var turn1 : int
var turn2 : int
var turn3 : int
var turn4 : int
var turn5 : int
var oturn : int
var oturn1 : int
var oturn2 : int
var oturn3 : int
var oturn4 : int
var face :int := Pic.FileNew ("happyface.jpg")
var finished : int := 45
var intfont : int
%Music
process playstuff
    loop
        Music.PlayFile ("song.mp3")
    end loop
end playstuff

fork playstuff



%Home page

Pic.Draw (HomePage, CenterX, CenterY, 0)
delay (5000)
cls
%ASking the player if the want to play
intfont:=Font.New ("TimesNewRoman:15")
Font.Draw  ("Would you like to play the game, yes or no? This is a two player game so please bring a friend",2,900,intfont,green)
get reply
if reply = "no" then
    put "Too bad... your missing out on a great game"
end if
if reply = "yes" then
    put "Welcome to the best TIC TAC TOE game ever!!"
    %Asking the player if they would like to see the instrcutions
    put "Would you like to read the instructions? yes or no"
    get answer
    if answer = "no" then
        put "Begin to play"
        delay (500)
        cls
    elsif answer = "yes" then
    intfont := Font.New ("TimesNewRoman:15")
    Font.Draw ("To play this game you must use your number pad to access the playing field.",5,430,intfont,green)
    Font.Draw ("The number '7' would allow you to access the top left part of the the table",5,400,intfont,green)
    Font.Draw ("and the rest of the numbers would allow you to access the part of the graph",5,370,intfont,green)
    Font.Draw ("in which they are located.",5,340,intfont,green)   
    Font.Draw ("Are you now ready to play? yes or no",5,310,intfont,green) 
                get choice
        if choice = "yes" then
            put "Wonderful!!"
            cls
        elsif choice = "no" then
            put "too bad the game is about to start"
            cls

        end if
    end if

end if
%Actual screen that the player plays on
if reply = "yes" then
    drawbox (100, 100, 200, 200, 1)                     % bottom-left
    drawbox (200, 100, 300, 200, 1)                         % bottom-centre
    drawbox (300, 100, 400, 200, 1)                         % bottom-right
    drawbox (100, 200, 200, 300, 1)                         % mid-left
    drawbox (200, 200, 300, 300, 1)                         % mid-centre
    drawbox (300, 200, 400, 300, 1)                         % mid-right
    drawbox (100, 300, 200, 400, 1)                         % top-left
    drawbox (200, 300, 300, 400, 1)                         % top-centre
    drawbox (300, 300, 400, 400, 1)                         % top-right
    %x's turn
    loop
        put "X's turn,choose location"              %Tells the X user to input their answer
        get turn1


        if turn1 = 1 then
            Pic.Draw (xpic, 130, 134, 0)            %Shows X in the certian location
        elsif turn1 = 2 then
            Pic.Draw (xpic, 229, 134, 0)            %Shows X in the certian location
        elsif turn1 = 3 then
            Pic.Draw (xpic, 323, 134, 0)            %Shows X in the certian location
        elsif turn1 = 4 then
            Pic.Draw (xpic, 130, 224, 0)            %Shows X in the certian location
        elsif turn1 = 5 then
            Pic.Draw (xpic, 232, 232, 0)            %Shows X in the certian location
        elsif turn1 = 6 then
            Pic.Draw (xpic, 327, 232, 0)            %Shows X in the certian location
        elsif turn1 = 7 then
            Pic.Draw (xpic, 130, 326, 0)            %Shows X in the certian location
        elsif turn1 = 8 then
            Pic.Draw (xpic, 231, 330, 0)            %Shows X in the certian location
        elsif turn1 = 9 then
            Pic.Draw (xpic, 329, 327, 0)            %Shows X in the certian location

        end if

        %Cirlces turn

        put "circle's turn,choose location"     %Tells the CIRCLE user to input their answer
        get oturn

        if oturn = 1 then
            Pic.Draw (opic, 130, 134, 0)        %Shows the CIRCLE in the certain location
        elsif oturn = 2 then
            Pic.Draw (opic, 229, 134, 0)        %Shows the CIRCLE in the certain location
        elsif oturn = 3 then
            Pic.Draw (opic, 323, 134, 0)        %Shows the CIRCLE in the certain location
        elsif oturn = 4 then
            Pic.Draw (opic, 130, 224, 0)        %Shows the CIRCLE in the certain location
        elsif oturn = 5 then
            Pic.Draw (opic, 232, 232, 0)        %Shows the CIRCLE in the certain location
        elsif oturn = 6 then
            Pic.Draw (opic, 327, 232, 0)        %Shows the CIRCLE in the certain location
        elsif oturn = 7 then
            Pic.Draw (opic, 130, 326, 0)        %Shows the CIRCLE in the certain location
        elsif oturn = 8 then
            Pic.Draw (opic, 231, 330, 0)        %Shows the CIRCLE in the certain location
        elsif oturn = 9 then
            Pic.Draw (opic, 329, 327, 0)        %Shows the CIRCLE in the certain location
        end if
       %X's turn
         put "X's turn"                         %Tells the X user to input their answer
        get turn2

        if turn2 = 1 then
            Pic.Draw (xpic2, 130, 134, 0)       %Shows X in the certian location
        elsif turn2 = 2 then
            Pic.Draw (xpic2, 229, 134, 0)       %Shows X in the certian location
        elsif turn2 = 3 then
            Pic.Draw (xpic2, 323, 134, 0)       %Shows X in the certian location     
        elsif turn2 = 4 then
            Pic.Draw (xpic2, 130, 224, 0)       %Shows X in the certian location
        elsif turn2 = 5 then
            Pic.Draw (xpic2, 232, 232, 0)       %Shows X in the certian location
        elsif turn2 = 6 then
            Pic.Draw (xpic2, 327, 232, 0)       %Shows X in the certian location
        elsif turn2 = 7 then
            Pic.Draw (xpic2, 130, 326, 0)       %Shows X in the certian location
        elsif turn2 = 8 then
            Pic.Draw (xpic2, 231, 330, 0)       %Shows X in the certian location
        elsif turn2 = 9 then
            Pic.Draw (xpic2, 329, 327, 0)       %Shows X in the certian location
        end if
        % Cirlce's turn
        put "cirlce's turn"                     %Tells the CIRCLE user to input their answer
        get oturn2

        if oturn2 = 1 then
            Pic.Draw (opic2, 130, 134, 0)       %Shows the CIRCLE in the certain location
        elsif oturn2 = 2 then
            Pic.Draw (opic2, 229, 134, 0)       %Shows the CIRCLE in the certain location
        elsif oturn2 = 3 then
            Pic.Draw (opic2, 323, 134, 0)       %Shows the CIRCLE in the certain location
        elsif oturn2 = 4 then
            Pic.Draw (opic2, 130, 224, 0)       %Shows the CIRCLE in the certain location
        elsif oturn2 = 5 then
            Pic.Draw (opic2, 232, 232, 0)       %Shows the CIRCLE in the certain location
        elsif oturn2 = 6 then
            Pic.Draw (opic2, 327, 232, 0)       %Shows the CIRCLE in the certain location
        elsif oturn2 = 7 then
            Pic.Draw (opic2, 130, 326, 0)       %Shows the CIRCLE in the certain location
        elsif oturn2 = 8 then
            Pic.Draw (opic2, 231, 330, 0)       %Shows the CIRCLE in the certain location
        elsif oturn2 = 9 then
            Pic.Draw (opic2, 329, 327, 0)       %Shows the CIRCLE in the certain location

        end if
        % X's turn
        put "X's turn"                           %Tells the X user to input their answer
        get turn3

        if turn3 = 1 then
            Pic.Draw (xpic3, 130, 134, 0)       %Shows X in the certian location
        elsif turn3 = 2 then
            Pic.Draw (xpic3, 229, 134, 0)       %Shows X in the certian location
        elsif turn3 = 3 then
            Pic.Draw (xpic3, 323, 134, 0)       %Shows X in the certian location
        elsif turn3 = 4 then
            Pic.Draw (xpic3, 130, 224, 0)       %Shows X in the certian location
        elsif turn3 = 5 then
            Pic.Draw (xpic3, 232, 232, 0)       %Shows X in the certian location
        elsif turn3 = 6 then
            Pic.Draw (xpic3, 327, 232, 0)       %Shows X in the certian location
        elsif turn3 = 7 then
            Pic.Draw (xpic3, 130, 326, 0)       %Shows X in the certian location
        elsif turn3 = 8 then
            Pic.Draw (xpic3, 231, 330, 0)       %Shows X in the certian location
        elsif turn3 = 9 then
            Pic.Draw (xpic3, 329, 327, 0)       %Shows X in the certian location
        end if
        % Circle's turn
        put "cirlce's turn"                     %Tells the CIRCLE user to input their answer
        get oturn3

        if oturn3 = 1 then
            Pic.Draw (opic3, 130, 134, 0)      %Shows the CIRCLE in the certain location
        elsif oturn3 = 2 then
            Pic.Draw (opic3, 229, 134, 0)      %Shows the CIRCLE in the certain location
        elsif oturn3 = 3 then
            Pic.Draw (opic3, 323, 134, 0)      %Shows the CIRCLE in the certain location
        elsif oturn3 = 4 then
            Pic.Draw (opic3, 130, 224, 0)      %Shows the CIRCLE in the certain location
        elsif oturn3 = 5 then
            Pic.Draw (opic3, 232, 232, 0)      %Shows the CIRCLE in the certain location
        elsif oturn3 = 6 then
            Pic.Draw (opic3, 327, 232, 0)      %Shows the CIRCLE in the certain location
        elsif oturn3 = 7 then
            Pic.Draw (opic3, 130, 326, 0)      %Shows the CIRCLE in the certain location
        elsif oturn3 = 8 then
            Pic.Draw (opic3, 231, 330, 0)      %Shows the CIRCLE in the certain location
        elsif oturn3 = 9 then
            Pic.Draw (opic3, 329, 327, 0)      %Shows the CIRCLE in the certain location

        end if

        % X's turn
        put "X's turn"                          %Tells the X user to input their answer
        get turn4

        if turn4 = 1 then
            Pic.Draw (xpic4, 130, 134, 0)       %Shows X in the certian location
        elsif turn4 = 2 then
            Pic.Draw (xpic4, 229, 134, 0)       %Shows X in the certian location
        elsif turn4 = 3 then
            Pic.Draw (xpic4, 323, 134, 0)       %Shows X in the certian location
        elsif turn4 = 4 then
            Pic.Draw (xpic4, 130, 224, 0)       %Shows X in the certian location
        elsif turn4 = 5 then
            Pic.Draw (xpic4, 232, 232, 0)       %Shows X in the certian location
        elsif turn4 = 6 then
            Pic.Draw (xpic4, 327, 232, 0)       %Shows X in the certian location
        elsif turn4 = 7 then
            Pic.Draw (xpic4, 130, 326, 0)       %Shows X in the certian location
        elsif turn4 = 8 then
            Pic.Draw (xpic4, 231, 330, 0)       %Shows X in the certian location
        elsif turn4 = 9 then
            Pic.Draw (xpic4, 329, 327, 0)       %Shows X in the certian location
        end if
        % Circle's turn
        put "cirlce's turn"                     %Tells the CIRCLE user to input their answer
        get oturn4

        if oturn4 = 1 then
            Pic.Draw (opic4, 130, 134, 0)       %Tells the CIRCLE user to input their answer
        elsif oturn4 = 2 then
            Pic.Draw (opic4, 229, 134, 0)       %Tells the CIRCLE user to input their answer
        elsif oturn4 = 3 then
            Pic.Draw (opic4, 323, 134, 0)       %Tells the CIRCLE user to input their answer
        elsif oturn4 = 4 then
            Pic.Draw (opic4, 130, 224, 0)       %Tells the CIRCLE user to input their answer
        elsif oturn4 = 5 then
            Pic.Draw (opic4, 232, 232, 0)       %Tells the CIRCLE user to input their answer
        elsif oturn4 = 6 then
            Pic.Draw (opic4, 327, 232, 0)       %Tells the CIRCLE user to input their answer
        elsif oturn4 = 7 then
            Pic.Draw (opic4, 130, 326, 0)       %Tells the CIRCLE user to input their answer
        elsif oturn4 = 8 then
            Pic.Draw (opic4, 231, 330, 0)       %Tells the CIRCLE user to input their answer
        elsif oturn4 = 9 then
            Pic.Draw (opic4, 329, 327, 0)       %Tells the CIRCLE user to input their answer
   
        end if
        %X's turn
        put "X's turn"                          %Tells the X user to input their answer
        get turn5

        if turn5 = 1 then
            Pic.Draw (xpic5, 130, 134, 0)       %Shows X in the certian location
        elsif turn5 = 2 then
            Pic.Draw (xpic5, 229, 134, 0)       %Shows X in the certian location
        elsif turn5 = 3 then
            Pic.Draw (xpic5, 323, 134, 0)       %Shows X in the certian location
        elsif turn5 = 4 then
            Pic.Draw (xpic5, 130, 224, 0)       %Shows X in the certian location
        elsif turn5 = 5 then
            Pic.Draw (xpic5, 232, 232, 0)       %Shows X in the certian location
        elsif turn5 = 6 then
            Pic.Draw (xpic5, 327, 232, 0)       %Shows X in the certian location
        elsif turn5 = 7 then
            Pic.Draw (xpic5, 130, 326, 0)       %Shows X in the certian location
        elsif turn5 = 8 then
            Pic.Draw (xpic5, 231, 330, 0)       %Shows X in the certian location
        elsif turn5 = 9 then
            Pic.Draw (xpic5, 329, 327, 0)       %Shows X in the certian location
        end if
        delay (500)
       cls
      %End Page
       intfont := Font.New ("TimesNewRoman:22")
       Font.Draw ("Thank you for playing our game, please come again!", 10, 10, intfont, green)
         Pic.Draw (face, 581, 364, 0)
         delay (5000)
    exit when turn1 + turn2 + turn3 + turn4 + turn5 + oturn + oturn1 + oturn2 + oturn3 + oturn4 = 45
       
    end loop
end if



Please specify what version of Turing you are using
4.1.1
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Thu Jan 10, 2013 3:01 pm   Post subject: RE:turing (tic tac toe)

Banana, you posted this same post 4 times in different forums... Don't spam the same help topic, it won't get you help any faster and may even turn people off from helping you. Moreover, it helps if you use proper English in your posts... it's obvious you are capable of this, since your code contains decent English, so put in the effort when asking for help.

In the future, use more descriptive topic titles ("turing" means nothing in the Turing Help forum) and describe your problem in more detail.

What code have you tried already to detect the winner? Hint: You're going to have to keep track of the state of each of the squares on the tic-tac-toe board, and look for three in a row. There are only 8 (each row + each column + each diagonal) x 2 (Os, Xs) possibilities for a winning board that you have to check for.
jky09




PostPosted: Thu Jan 10, 2013 3:42 pm   Post subject: Re: turing (tic tac toe)

Try using a procedure and use if statements.
And by the way, I found a spelling error in "Shows X in CERTIAN position"
Insectoid




PostPosted: Fri Jan 11, 2013 9:34 am   Post subject: RE:turing (tic tac toe)

Quote:
Try using a procedure and use if statements.


This is like a hockey coach saying "Try using your skates and your stick". It really doesn't help at all.
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  [ 4 Posts ]
Jump to:   


Style:  
Search: