How to make your Tic Tac Toe game unbeatable by using the minimax algorithm
ahmad abdolsaheb
3.2K36

Excellent explanation! This inspired me to write my own version, and it seems to work (most of the time). However, I am able to win sometimes.

The below images detail how I won (I am X):

Here is my log:

What I believe the problem is that it does not correctly choose which of the maximum scores to use, such as on the last AI turn where it chooses 3 rather than 8.