Computer Science Canada

Slight Tic-Tac-Toe problem

Author:  TheFerret [ 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

Author:  AsianSensation [ Wed Mar 17, 2004 11:54 pm ]
Post subject: 

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

Author:  TheFerret [ Thu Mar 18, 2004 12:09 am ]
Post 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)
procedure win ()


        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
 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
    win ()
end if
end aga

Author:  AsianSensation [ Thu Mar 18, 2004 9:08 am ]
Post 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.

forward proc A
forward proc B

body proc A
end A

body proc B
end B

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

Author:  TheFerret [ Thu Mar 18, 2004 1:57 pm ]
Post subject: 

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

Author:  AsianSensation [ Thu Mar 18, 2004 2:04 pm ]
Post 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.

Author:  recneps [ Thu Mar 18, 2004 3:57 pm ]
Post 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