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

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




PostPosted: Wed Mar 17, 2004 11:36 pm   Post subject: Slight Tic-Tac-Toe problem

I made a Tic-Tac-Toe game and it works good but when you hit yes to play again and put in 2 x's and 2 o's it stops and says it is finished and I have tried changing stuff around and nothing works...

P.S. My code is probally so un effiecent



revisedtictactoe.t
 Description:
Here it is

Download
 Filename:  revisedtictactoe.t
 Filesize:  5.84 KB
 Downloaded:  724 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
AsianSensation




PostPosted: Wed Mar 17, 2004 11:54 pm   Post subject: (No subject)

did you also reset fill? That might be the problem, from a cursory glance anyways.
TheFerret




PostPosted: Thu Mar 18, 2004 12:09 am   Post subject: (No subject)

That fixed but another question, how can you put a procedure in a process and have the procedure below work... exp...(I took out a big part of the code)
code:
procedure win ()

    loop

        draw ()

        xes ()
        exit when
        oes ()
        % fork winner ()
        exit when
    end loop
    if  then
        put "X Wins!!!"
        xs += 1
        start := 1
        fork aga()
    end if
    if then
        put "O Wins!!!"
        ys += 1
        start := 1
        fork aga()
    end if
end win
win
 process aga()
put "Play again, y/n"
get again
if again = "y" or again = "Y" then
    a := 0
    b := 0
    c := 0
    d := 0
    e := 0
    f := 0
    g := 0
    h := 0
    j := 0
    start := 0
    fill:=0
    cls
    win ()
else
end if
end aga
AsianSensation




PostPosted: Thu Mar 18, 2004 9:08 am   Post subject: (No subject)

well, first of all, I wouldn't try to use processes, it's very inaccurate for the things you want to do. But if you really want to do this, function prototype it.

use forward.

code:
forward proc A
forward proc B

body proc A
    B
end A

body proc B
    A
end B


notice how you can't use forward with processes. So you have to prototype the procedure only.
TheFerret




PostPosted: Thu Mar 18, 2004 1:57 pm   Post subject: (No subject)

It works, here is my Tic-Tac-Toe game...


revisedtictactoe.t
 Description:

Download
 Filename:  revisedtictactoe.t
 Filesize:  5.92 KB
 Downloaded:  504 Time(s)

AsianSensation




PostPosted: Thu Mar 18, 2004 2:04 pm   Post subject: (No subject)

slight problem, I don't think you checked for input on the same spot. That means I can input square 1 as the coordinate for 9 times. Should fix that, I dont see any other problems so far, gj.
recneps




PostPosted: Thu Mar 18, 2004 3:57 pm   Post subject: (No subject)

for some more ideas, check out my fp, the source code is there, show you how i made it so that you couldnt click on a used sq Smile
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  [ 7 Posts ]
Jump to:   


Style:  
Search: