So over the past few weeks I have been working with Tic Tac Toe AI in an attempt integrate a bot into my Tic Tac Toe program, making it playable by just 1 person. The bot is coming along well, but through this process I have been reminded of the arduousness of creating AI. While the process has been incredibly fun, programming a bot to respond educatedly to every possible move made by a human is no small task. In addition to that, the bot must also take into account it’s own previous moves in order to construct the best, most likely to be successful, strategy.
To conquer this task I have been mapping every possible state of the tic tac toe board at every point of the game, taking into account the preset moves of the AI as well as every move that may be made by the human player. The mapping looks like this:
Using these notes I’m able to quickly assess which moves the bot should have programmed into itself, as well as which moves would never be necessary. For example, the bot will always try to go for the middle box (box 5) for it’s first move, but if that box is taken, it will default to the bottom right corner (box 9). Therefore, the bot will never encounter a situation in which the human player has both box 5 & box 9, so it does not need to have a response to that situation. While that is a very simple example, as the game progresses and the board becomes more complex, the number of situations which the bot could never face multiplies rapidly. Keeping track of these situations is crucial to creating clean, well organized code, as well as keeping the bot as efficient as possible. Below is some output from the unfinished bot. The bot should be finished and posted by early next week!