JavaScript EditorFree JavaScript Editor     Ajax Editor 

Main Page
  Previous Section Next Section


So, what is AI anyway? What are the goals and conditions that differentiate a good AI system from a bad one? Essentially, bad AI design often starts by setting the wrong goals.

One definition of AI might be something like "AI is the computer simulation of intelligent behavior." This would be valid except for the fact that we really don't know for sure what intelligence is. Does "intelligence" mean "behavior that exhibits great ability to adapt and solve complex problems," or is it "behavior that is close to that of humans"? History shows us again and again that humans are not always brilliant, yet there is a quality to their behavior that makes them intelligent. As you will learn in this chapter, some games make the mistake of trying to follow the first definition, and by doing so, produce results that are completely unrealistic. Take, for example, one of the classic AI problems—finding a route from point A to point B that avoids obstacles.

Many algorithms exist to solve this problem with varying degrees of success. They analyze the map and trace a path connecting the two endpoints and avoid any obstacles in-between. Some of them, however, go too far, ensuring that the path between A and B is optimal—that is, the shortest possible path. This is the case in the popular A* algorithm, which we will cover in Chapter 8, "Tactical AI." According to the first definition, A* is clearly a very intelligent algorithm. In fact, it is so intelligent that it can algorithmically build optimal paths between two endpoints, even if we have to cross many miles and obstacles in the process. But it's completely unrealistic when compared to the behavior of a human being. Humans do not trace optimal paths, and they often make mistakes traversing very complex labyrinths (see Figure 6.1).

Figure 6.1. Comparison between A* and a human path finder. Left: initial problem. Middle: human. Notice how we try to approach the target, and if there's no path available, often bail out. Right: A* knows the solution beforehand so it traces a highly unrealistic but correct path through the top-right area.


A human going from A to B would follow the solid trajectory (assuming he didn't know the path beforehand), and A* would find the optimal, dotted solution. So, a game using this method might be quite smart, but not very realistic. And this is of extreme importance because concentrating on having a "smart" AI but not a "human" AI can sometimes yield poor gameplay, and that's a capital sin in game AI development. In other words, many times we will be able to create perfect AIs that will be frustrating for the human player. Thus, we will need to keep a reasonable degree of imperfection built into the AI design.

On the other hand, we do not want to create dumb AIs just for the sake of realism. Games are about challenges, and these require smart enemies, which, to an extent, are hard to beat. A good example is a real-time strategy game. The computer creates a strategy for the CPU-controlled army using a variety of techniques. But soldiers on the AI-controlled side are very shallow in terms of the spontaneity and improvisational value of their performance. They are more like robots designed to carry out a master plan. This must be so or the game would be too easy and become boring.

So clearly, game AI is a balance between generating behavior that is both highly evolved and sophisticated, and behavior that is more or less human (in the nonoptimal sense of the word). Several techniques can be used to ensure that our AIs are not just "problem solving robots" but lifelike entities that provide just the right amount of complexity to be challenging and engaging, but not more than that.

      Previous Section Next Section

    JavaScript EditorAjax Editor     JavaScript Editor