Tic Tac Toe is a mecanical game, it has a finite, small number of possible combinations. You can teach an AI to always win or draw. Here is a small explanation.
First of all, it's not artificial intelligence. There are a couple of rules that make sure that you always win or draw (or in this case, that the AI wins or draws):
- If AI begins, it takes a random corner.
- If the player begins with a corner, AI takes the center. If not, AI takes a corner.
- Check for player doublets (dangerous doublets) and fill the holes to avoid loosing.
- If AI has a corner, AI tries to take another corner (this is the strategy to win... errr, to check if the player is attentive).
- If necessary, play randomnly.
So next time you play with a friend, try these simple rules. You'll be unbeatable as well.
Remember that loosing at Tic Tac Toe is linked with lack of attention. And maybe you be can inattentive, but a program cannot.