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

Username:   Password: 
 RegisterRegister   
 i need some help with human vs. computer
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
meidan




PostPosted: Wed Jun 14, 2006 10:11 pm   Post subject: i need some help with human vs. computer

in my tic tac toe game, how do i make the computer go after i go and wait till i go again???
Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: Wed Jun 14, 2006 10:13 pm   Post subject: (No subject)

think about it, Turing runs top down (with a few exceptions) so it makes sense to have the computer moves after the human moves right? simply code in what you want the computer to do after the human makes his/her move and then loop that whole section till the game is done Very Happy
upthescale




PostPosted: Thu Jun 15, 2006 8:27 pm   Post subject: (No subject)

Well my way of doing it wud be this...

sicne u have 9 boxes fer a tic tac toe u can make a variable and give it a value of randint


Code:

var random:int

randint(random,1,9)



now to make the computer choose one
go

code:

if number = 1 then
%Draw a box in the top left corner

elsif number = 2 then
%Draw a box in the top middle

elsif number = 3 then
%Draw a box in the top right corner

end if


And do the same with the other 6 boxes...

but wut if you place a box in the third box, and then the computer will generate a number 3, then the computer will go on top of your! to stop this, im not sure i havent tested it but you can do the following:

code:

if usersBox=1 and random = 1 then
randint(random,1,9)
end if


what that does is if you put yours in box number one, and so does the computer, turing will re-genrate a new number until not = 1

do that fer the other 8 boxes
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  [ 3 Posts ]
Jump to:   


Style:  
Search: