Computer Science Canada i need some help with human vs. computer |
Author: | meidan [ 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??? |
Author: | Clayton [ Wed Jun 14, 2006 10:13 pm ] |
Post 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 ![]() |
Author: | upthescale [ Thu Jun 15, 2006 8:27 pm ] | ||||
Post 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
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:
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 |