TicTacToe: Playing Against the Machine

TicTacToe is a simple game but it does have some tactical depth. With limited moves and turns it can be easy to create exhaustive search based solutions to implement the logic for a Player vs Computer game.

It is also the perfect game for anyone who wants to start with AI programming (e.g. Reinforcement Learning). Keeping this in mind I created a test-bed with two ‘brains’ – one that uses Induction (taking advantage of the finite state-space) and the other that uses Pattern Matching (taking advantage of the fixed grid nature of the game).

The code in python can be found on github:

https://github.com/amachwe/tictactoe

Here is the readme that explains how to use it:

https://github.com/amachwe/tictactoe/blob/main/README.md

Currently neither the Induction or Pattern Matching brain really learn anything. This is because we can do an active search of the full state space to plan each move (given the relatively small size of the state space).

Patterns in the Pattern Matching brain are provided as ‘knowledge’ but these can just as well be learnt using Reinforcement Learning methods.

Have fun playing the game or using it as a test-bed for your own AI Tic Tac Toe playing brain!

Feel free to comment to ask questions/provide suggestions!