At first, play the game normally. Every time you win, the AI in the game learns your moves and stops you when you try to replicate them. At the same time, (if you have it in hard mode,) the AI has strategy, blocking you if you have 2 in a row, and will win if it has 2 in a row. I'm sure you could figure out how to beat it though, right? ......right? P.S. tell me if you like the effect :)
This is really exciting for me, I've always wanted to code a learning AI, and even though this is super simple, it's still cool. The controls are super simple as well: click the box you want to place an X, and the AI will go. if you want to reset, press R. Just be aware, the more you play this, the smarter it gets... (yes, it does remember your past wins so be careful)