This is an unbeatable(!) version Tic-Tac-Toe that I created for Android devices using Java.
Essentially, in Tic-Tac-Toe, if your opponent makes zero mistakes throughout the whole game, the game can end in either tie or in the opponent's win.
So how can we ensure that our opponent is bound to make zero mistakes? And, more specifically, how can we turn it all into code?
Well, using the recursive Minimax algorithm, we evaluate all the possible outcomes, and choose the optimal move accordingly.
You can read more about the implementation of Minimax in Tic-Tac-Toe here: https://www.neverstopbuilding.com/blog/minimax