AI Basics

AI in games is really about creating bots that show a certain behavioral appearance, whether it's a rodent scampering along the ground or a human-shape creature making seemingly intelligent decisions. In this chapter, we use the term bot to refer to any "intelligent" game object. With convincing bots, AI can help define the feel of a game almost as much as the visual parts of the game. The appearance of the behavior is the important part. When designing the AI for a game, you should design from the top down: Think about how you want your bots to appear, and then try to implement it. It can be tempting to take AI design from a bottom-up approach by first designing complicated patterns and infrastructures. For example, perhaps you want to design different bots with different search patterns that just wander around a maze looking for the player. But in a 3D world, this might just appear to the player like bots randomly showing up to attack. So, think about how you want your AI creatures to appear to the player before you do anything. Of course, many AI bots need to start with a good path-finding algorithm so that they know how to travel from any two points in a map. Without path finding, you could end up with annoying or distracting AI that makes bots get stuck next to walls or not be able to turn around a corner. You can use the A* algorithm implemented in the previous chapter. On that note, one of your overall goals of your AI bots is to not be distracting. Little things such as bots moving around in unnatural patterns can be annoying to the user. Sometimes AI is noticeable only when it's bad. You also should try to give different characters different behaviors that match their appearance. For example, a human-shape creature would need to appear to make intelligent choices because users would expect a human-shape creature to do so; on the other hand, a spiderlike creature could follow simple patterns and still be believable. Another idea is to make progressively smarter and more difficult enemies as the game moves along. Stay away from AI that easily becomes predictable so that the game play doesn't become too tedious as the game progresses. Also, always keep in mind the goal of AI in the first place: finding that perfect zone where enemies are not too smart and not too dumb, making the game fun and challenging at the same time. Finding the right balance is up to you. In this chapter, you'll design an AI system to work with the 3D engine in this tutorial. The bots will exhibit slightly different personalities, and each bot will have different movement and attack patterns to distinguish themselves from the others.