Chapter 9. Playing Tic-Tac-Toe against an AI

We built the game Pac Man in the previous chapter. The enemies were not very smart; you can easily fool them. In this chapter, we will build a game in which the computer will play well. The game is called Tic-Tac-Toe. The game is played by two players on a grid, usually three by three. The players try to place their symbols three in a row (horizontal, vertical or diagonal). The first player can place crosses, the second player places circles. If the board is full, and no one has three symbols in a row, it is a draw.

The game is usually played on a three-by-three grid and the target is to have three symbols in a row. To make the application more interesting, we will make the dimension and the row length ...

Get TypeScript: Modern JavaScript Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.