
-----------------------------------
meidan
Wed Jun 14, 2006 10:11 pm

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???

-----------------------------------
Clayton
Wed Jun 14, 2006 10:13 pm


-----------------------------------
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 :D

-----------------------------------
upthescale
Thu Jun 15, 2006 8:27 pm


-----------------------------------
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 

 
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: 

 
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
