Tic Tac Toe and Minimax

This week I’ve been facing down an old nemesis… Artificial Intelligence (AI). Specifically, AI in video games. Back when I first started “developing” video games, I did my upmost to avoid the dangerously difficult topic of AI. Every time I thought about AI, I was pleasantly reminded of how much I didn’t know (and I still don’t know). AI is such a vast field. It involves data structures, algorithms, and complex systems that when combined with everything else required of a video game can leave a novice developer hiding in the corner. But not anymore! I conquered my first challenge by building a Tic-Tac-Toe AI that is guaranteed not to lose. It will either win or draw.