Tic Tac Toe AI with Machine Learning I am new to machine learning and as one of my first projects I decided to make a tic tac toe bot. What I've done so far is a rgb/hex color recognition with the naive bayes algorithm, which was really simple to make. Now I am struggling a bit with making a tic tac toe bot. 
My question is how should I proceed with this, is there a dataset, and should I take naive bayes again, or decision tree would be better for tic tac toe? (once again, purpose is just that I learn and dive deeper in machine learning)
 A: I am working on a very similar project to you, and I'm also doing it as an introduction to machine learning.
One of the best methods I've seen for getting a tic-tac-toe AI is a reinforcement learning method described in this paper and formally discussed in this book.
Basically, you have a program run through possible moves and then update probability of how likely that move is to be correct based on whether or not it ends up winning when playing against a random player.
If the player is not random, or you would like a more formal analysis, you can use minimax or alpha-beta pruning as detailed here. Then, I'd recommend training a neural network on the data you've received for an additional challenge.
You can also use more advanced methods such as the Monte Carlo Tree Search (similar to the reinforcement learning method above).
A: Presumably you don't want an AI which looks ahead a few moves and brute-forces the best move. I guess you want an AI which will evaluate the strength of each possible move and choose the best.
One way you can approach this is to train an AI to take an input of the board and an input of where to play next and output a probability that this move will lead to a win.
You can create your own data by playing this AI against itself or against a player which plays randomly. This is more involved than using a dataset with the best moves listed for many positions, it's an option if you can't find such a dataset or if you want a challenge.
One possible way to create your own data and use it to iteratively improve the AI is the following:


*

*Let the AI play a few moves and then pause the game

*Select a random move to play (random allows the AI to learn from moves it wouldn't normally make)

*Record the state of the game and the new move

*Let the AI finish the game and record the result


This approach will create game data with many positions and many actions taken with the expected win/loss/draw result. You can use this data to train an AI to predict the result of the game if a given move is played. Repeat this training cycle to iteratively improve the AI.
A: I have just finished making a tictactoe bot. 
The way I have set it up is that it learns from the moves that I make. 
So, if I'm playing a PlayervsAI or PlayervsPlayer game, every move that the winner makes is recorded and saved in a file. So this data is essentially 'moves that lead up to a win'. The format of this data is the 'state of the board + position played'
So when the AI is playing, it looks at this data, sees if the current state of the board matches any in the saved moves file, then plays that move. If it cant find a match it just looks for a win, or a block or just random.
As TicTacToe has an optimal strategy, technically you could input all the optimal moves manually, but I found it more interesting 'teaching' the AI. 
