Artificial intelligence (AI) algorithms are used to determine the actions of computer-controlled entities in games. This chapter covers three useful game AI techniques: changing behaviors with state machines, computing paths for entities to move through the world (pathfinding), and making decisions in two-player turn-based games (minimax and game trees). The chapter shows you how to apply some of these AI techniques to create a tower defense game project.
State Machine Behaviors
For very simple games, the AI always has the same behavior. For instance, an AI for two-player Pong tracks the position of the ball as it moves. Because this behavior doesn’t change throughout the game, it’s stateless. But for more complex ...