Log in

View Full Version : tic tac toe question



herotm
11-11-2008, 11:50 PM
Check this code

http://pastebin.com/m1503a55f

How do I make it human vs computer instead of human vs human?

I tried many possibilities, I cant get anywhere, any guidance?

herotm
11-12-2008, 06:03 PM
anyone have ideas

Jack
11-12-2008, 07:09 PM
Sure, but you're gonna have to pay for it. :cool:

Demonicman
11-13-2008, 12:56 PM
using the random function aka $variable = rand(min,max); in a few places should get your artificial intelligence in no time

if you are looking for a random challenge, keep it simple and have one random variable from 1-9 indicating where on the board the marker shall be placed

if you are looking for say, 2 or 3 skills levels, use many if statements and random numbers to determine whether the ai should make the right move

for instance:

//computers turn
$random=rand(1,9);
if($random=1){
$postmarker;
}elseif($random=2){
$postmarker;
}

ect...

to add difficulty you will need to place checks to see where your markers are on the board to determine whether the computer should place there or not

good luck