Please anyone help with AI

The tic tac toe game is complete now I want to give it a brain. it sounded simple at first but none of my ideas are working and I feel I need guidance now.

You should check out MiniMax. This video will explain what it is but you will have to figure out to implement it yourself