TIC-TAC-TOE


How does it work?

This page uses an artificial intelligence algorithm called MiniMax to play Tic-Tac-Toe. The computer recursively creates a tree of all possible future moves. It then picks the most optimal move based on all possible human responses. In a simple game like Tic-Tac-Toe, where there are only a maximum of nine possible moves and the game must end within nine turns this algorithm can run quite quickly.

Because Tic-Tac-Toe is such a simple game, the computer can win or draw every time simply by using this algorithm. Whether you go first or second it is completely impossible to beat the computer. The best you can hope to achieve is a draw.

For more information on the MiniMax algorithm, see here. My implementation of the algorithm in TypeScript can be viewed here.