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 variable.
We will not create a graphical interface for this application, since we have already done that in Chapter 6 , Advanced Programming in TypeScript. We will only build the game mechanics and the artificial intelligence (AI). An AI is a player...