Use Machine learning principles to learn to play a perfect game of tic tac toe.