The only randomness is on the first turn where he chooses a random non middle spot to play otherwise I made the ai try to avoid winning as much as possible. Thanks for playing!