i need some help with human vs. computer
Author |
Message |
meidan
|
Posted: 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??? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Clayton
![](http://compsci.ca/v3/uploads/user_avatars/1718239683472e5c8d7e617.jpg)
|
Posted: 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 Very Happy](http://compsci.ca/v3/images/smiles/icon_biggrin.gif) |
|
|
|
|
![](images/spacer.gif) |
upthescale
|
Posted: 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 |
|
|
|
|
![](images/spacer.gif) |
|
|