I'm making a tic-tac-toe program. Player vs computer. I have most of the programming working, and I am now working on the computer's moves. I'm looking for the best way to go about this. The only way i can figure, is working out all the possible combinations of X's and O's in the tic-tac-toe square, and programming a move for every possible combination.
Ex:
Is this the only way to do this (there would be ALOT of combinations to program)? Or is there a better way?Code:if(firstsquare = x & secondsquare = x)
have the computer mark third square O.
else if(first square = x & fourthsquare = x)
have the computer mark the seventh square o.
...
Thanks.