This was my first graphical game and the project I made before Blackjack. I built the board, menus, scorekeeping, local two-player mode, and three computer difficulties in one Python file. It was mostly an excuse to learn Pygame, but it became a complete little game along the way.
The computer player
The hard difficulty does not use machine learning or a huge game tree. It looks for immediate wins and blocks, scores the remaining routes through each empty square, and handles one important fork as a special case. Medium sometimes chooses a random move instead, and easy is more random again.
What I learned
Every X, O, line, button, and score box is drawn from dimensions calculated in the program. Building that interface gave me the Pygame experience I used for the much larger Blackjack project next.