-
Tic-Tac-Toe help needed
I am at the moment writing functions that will simulate an intelligent computer AI. I can get the 2 player function to work, but I cannot even think of a way to do a computer algorithm besides getting every single possible move that can happen and using them in huge if statements. Help plz.
-
www.generation5.org
There's some good AI info on that site... especially for the type of problem you're using it for.
-
AI for tictactoe is just a simple case of...
If win_poss then win
if loss_poss then stop_loss( sometimes its possible to lose on more than 1 square. You can only stop one).
else take random untaken square.
-
Or you could go through every possibility, and see which move gives you the best chance of winning.
-
As a matter of fact, if the computer moves second, it can always force a draw. If it moves first, then it can play in the center, which is a winning strategy if the other player doesn't play on a corner.
-
the best algorithm (but hard) to implement for your tictactoe ai is the minimax tree.
-
my friend and i were bored in algebra class one day and decided to play tic tac toe, lol. anyways, there are SO many strategies to win a tic tac toe game.
examples:
1: take one corner
if the middle is not taken take the opposite corner diagonally, if that is taken, take any corner
take a corner that will possibly seal the win
2: take a center square on the border
take a corner on the other side of board
take another corner
3: take center
take a center on the border
take any corner
just write strategies that could possibly work. then base your ai reactions on what strategies could be used.