O'Reilly logo

TypeScript Blueprints by Ivo Gabe de Wolff

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required