Using reinforcement learning to play Tic Tac Toe: Basically implement the algorithm in the book -- Reinforcement Learning: An Introduction by Richard S. Sutton and Andrew G. Barto, 2nd edition (Chapter 1.4).
Download the "human_computer2.py" and "Optimal_Both2" files, and put them in the same directory, and now run the "human_computer2.py".
Now, you can play Tic-Tac-Toe with the trained computer player! Trust me, you will never win!