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

Username:   Password: 
 RegisterRegister   
 seriously i need help bad
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
matt




PostPosted: Mon Jan 24, 2005 9:07 pm   Post subject: seriously i need help bad

hi everyone i need ytur help as how to wright a procedure so that i can cheack the boxes in my tic tac toe turing. if i make it so an x is placed down in my program the ai seems to be able to goi over my x. For example if I place my x in the top left hand corner oft the tic tac toe box the ai has a chance to go over it. please help me with a procedure that will make mny boxes stop from being taken over. as well i am sure as to how to end my pogram when it gets three in a row any suggestions

*****************************
hey guys to make it work there is one cspecial thing u must go into paint and draw x and o and name them work.bmp and work2.bmp thats why this program is so frigan hard i no it takes time please helpm me nothing like this has ever been attempted before
____________________________________________________________-
_________________________________________________________________



code:
var yes: string
var no: string
var ansuer: string
var x, y : int


setscreen ("graphics: 450;225")
Pic.ScreenLoad ("title.bmp", 100, 0, picCopy)
delay (3000)


%Variables
var cheak : array 1 .. 3, 1 .. 3 of string (1)
var b : int



% initialize grid
for row : 1 .. 3
    for column : 1 .. 3
        cheak (row, column) := "-"
    end for
end for




% Draw the x and o grid
setscreen ("graphics: 300;300")
drawline (0, 100, 300, 100, black)
drawline (0, 200, 300, 200, black)
drawline (100, 0, 100, 300, black)
drawline (200, 0, 200, 300, black)
drawline (101, 0, 101, 300, black)
drawline (201, 0, 201, 300, black)
drawline (301, 201, 0, 201, black)
drawline (0, 101, 301, 101, black)
drawbox (0, 299, 299, 0, black)

loop

    loop
        mousewhere (x, y, b)
        if b = 1 then

            if x > 0 and x < 100 and y > 0 and y < 100 then

                Pic.ScreenLoad ("work.bmp", 0, 0, picCopy)

            elsif x > 100 and x < 200 and y > 0 and y < 100 then

                Pic.ScreenLoad ("work.bmp", 100, 0, picCopy)


            elsif x > 200 and x < 300 and y > 0 and y < 100 then

                Pic.ScreenLoad ("work.bmp", 200, 0, picCopy)

            elsif x > 0 and x < 100 and y > 100 and y < 200 then

                Pic.ScreenLoad ("work.bmp", 0, 100, picCopy)

            elsif x > 100 and x < 200 and y > 100 and y < 200 then

                Pic.ScreenLoad ("work.bmp", 100, 100, picCopy)

            elsif x > 200 and x < 300 and y > 100 and y < 200 then

                Pic.ScreenLoad ("work.bmp", 200, 100, picCopy)

            elsif x > 0 and x < 100 and y > 200 and y < 300 then

                Pic.ScreenLoad ("work.bmp", 0, 200, picCopy)

            elsif x > 100 and x < 200 and y > 200 and y < 300 then

                Pic.ScreenLoad ("work.bmp", 100, 200, picCopy)

            elsif x > 200 and x < 300 and y > 200 and y < 300 then

                Pic.ScreenLoad ("work.bmp", 200, 200, picCopy)

            end if
        end if

        exit when b = 1

    end loop

    delay (1000)
   
    loop
        randint (x, 0, 300)

        randint (y, 0, 300)


        if x > 0 and x < 100 and y > 0 and y < 100 then
            Pic.ScreenLoad ("work2.bmp", 0, 0, picCopy)

        elsif x > 100 and x < 200 and y > 0 and y < 100 then

            Pic.ScreenLoad ("work2.bmp", 100, 0, picCopy)

        elsif x > 200 and x < 300 and y > 0 and y < 100 then

            Pic.ScreenLoad ("work2.bmp", 200, 0, picCopy)

        elsif x > 0 and x < 100 and y > 100 and y < 200 then

            Pic.ScreenLoad ("work2.bmp", 0, 100, picCopy)

        elsif x > 100 and x < 200 and y > 100 and y < 200 then

            Pic.ScreenLoad ("work2.bmp", 100, 100, picCopy)

        elsif x > 200 and x < 300 and y > 100 and y < 200 then

            Pic.ScreenLoad ("work2.bmp", 200, 100, picCopy)

        elsif x > 0 and x < 100 and y > 200 and y < 300 then

            Pic.ScreenLoad ("work2.bmp", 0, 200, picCopy)

        elsif x > 100 and x < 200 and y > 200 and y < 300 then

            Pic.ScreenLoad ("work2.bmp", 100, 200, picCopy)

        elsif x > 200 and x < 300 and y > 200 and y < 300 then

            Pic.ScreenLoad ("work2.bmp", 200, 200, picCopy)

        end if
        exit
    end loop
end loop

end if
_________________________________________________________________
Sponsor
Sponsor
Sponsor
sponsor
cycro1234




PostPosted: Mon Jan 24, 2005 9:11 pm   Post subject: (No subject)

We won't be able to see hte pictures if you don't upload them.
ste_louis26




PostPosted: Mon Jan 24, 2005 9:24 pm   Post subject: (No subject)

We don't do the work for you on compsci we just give suggestions. You have no basic text to test box if it's x or o.-it's just a bunch of pictures-
matt




PostPosted: Mon Jan 24, 2005 10:25 pm   Post subject: (No subject)

sorry about that i will reword my problem thank u for pointing it out
Leftover




PostPosted: Tue Jan 25, 2005 12:38 am   Post subject: (No subject)

Tic tac toe has been attempted before... And you can upload the pictures easily your self.
basketball4ever




PostPosted: Tue Jan 25, 2005 1:09 am   Post subject: (No subject)

use a 2d array or just an if statement... kind of procedure

2D array --> go check out the tutorials

If statement... i guess u can just go like:
if %the coordinates of the box then
Draw.ThickLine(%watever)
then u make sure that the ai cant press these coordinates... and rand the other coordinates.. u'll have a crappy AI but ... tic tac toe... u can rreally have a medium ai....
ste_louis26




PostPosted: Tue Jan 25, 2005 12:05 pm   Post subject: (No subject)

You could test the box the see if it's been played with whatdot colour. It would be more code but not as much thinking.
cycro1234




PostPosted: Tue Jan 25, 2005 12:52 pm   Post subject: (No subject)

Don't spam the help section!!
Sponsor
Sponsor
Sponsor
sponsor
matt




PostPosted: Wed Jan 26, 2005 8:06 pm   Post subject: please give me an example of a 2d array

plaease give me an example of a 2d array
scottyrush13




PostPosted: Wed Jan 26, 2005 8:33 pm   Post subject: (No subject)

matt the isu's were due in class today

i doubt he'll let you hand it in on the exam day,
person




PostPosted: Wed Jan 26, 2005 8:36 pm   Post subject: (No subject)

code:
var a : array 1..5 of int
for x : 1..5
         a (x) := x
end for


for this, code, a (1) = 1, and 1 (2) = 2 and etc
this is all in turing help
scottyrush13




PostPosted: Wed Jan 26, 2005 8:38 pm   Post subject: (No subject)

matt, before you start asking questions about 2d arrays and such, you should check the tutorials, because im almost certain that there is something about them there

they arent all that difficult and i do believe that tony mentioned them in his arrays tutorial

check the tutorials before asking a question thats already been answered elsewhere
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: