AI in Game Programming
AI in Game Programming
In practice, the purpose of the AI system in the game engine is to control every aspect of the NPC. For example, within computer games—and not only first-person shooters—the AI must provide the following:
-
Primitive behaviors such as picking up items, pressing switches, using objects, performing purposeful gestures, and so on
-
Movement between areas of the game environment and dealing with obstacles, doors, or platforms
-
Decision making on a higher-level to decide which actions are necessary for the NPC to accomplish its tasks, and in what order
To develop systems capable of providing such control, a minimal amount of technology is necessary. Although standard programming techniques allow the implementation of intelligent NPCs, techniques from the field of AI can provide the following:
-
Elegant solutions for explicit control
-
Technology to support implicit control efficiently
Compared to standard scripting techniques, AI technology can be computationally more efficient and can generate better quality behaviors. Such improvements are possible thanks to various aspects of AI, discussed throughout this book:
-
AI techniques providing functionality such as motor control, pattern recognition, prediction, or approximation
-
Design patterns inserted at a system level to assemble these components together
-
Methodologies used to design and test behaviors within realistic environments
These AI methodologies allow the synthetic characters to come to life, but they also serve a particular purpose in games. Game development has common requirements that need to be taken into account when engineering the AI system. Two properties are important in games:
-
Entertainment— The AI can call upon the skills of human players. This involves providing them with various challenges and testing different abilities with increasing levels of difficulty. The AI also can play on emotions to increase entertainment value. The AI can trigger amazement by arranging cool events, or fright by building scary atmospheres.
-
Believability— The AI characters can improve immersiveness by doing their job in a way that does not distract attention from the mission of the game. As for realism, AI allows each individual NPC to behave in a plausible way that seems logically feasible to human players.
In summary, AI game development is about providing control to NPCs to produce entertainment (assisted by believability or realism). The next chapter takes the engineer's approach, using AI technology to assist in the creation of systems capable of such tasks.
Ref : By Alex J. Champandard
Designers Versus AI
Designers Versus AI
How do stronger AI technology and the potential for intelligent NPCs affect game design? It's clear that improvements in the field of AI have opened up possibilities for the design. In the near future, advancements will undoubtedly lead to other expansions in "design space."
However, intelligent NPCs are changing the methods of game design, too. These issues discussed in this section are causing tension within the development teams, and the subject is very topical. Clashes are a recurring theme—even among the very best developers.
Obstacles
Beyond any technical details, a major problem is making room for intelligent behavior in the design, and dealing with those behaviors:
-
Intelligent game characters can behave autonomously.
-
Designers need to control the behavior of NPCs.
An undeniable clash exists in these roles; do we actually need AI? If AI is present, do we need designers? The overlap lies between the designers' wishes and what the AI can provide. A reasonably intelligent NPC can challenge the authority of the designer!
Two Types of Games
Different attitudes toward control have led to two distinct varieties of video games. In the first variety, designers implement their vision in a top-down fashion, controlling every detail of the game. This is the explicit design approach. It's particularly common in games based on a single story line (Doom 3, Unreal 2).
When the design script is extremely detailed, such as in single-player scenarios, there is little need for AI techniques. It's even arguable whether NPCs are "intelligent" characters at all. (They do the same thing every time regardless of changes in the situation.) Standard programming or scripting can bring the design to life. The less detail there is in the story, the more AI technology is necessary.
The second type of game results from bottom-up design, whereby the AI and the environment combine and emerge into an interesting game. The key observation is that there is no master script. Working together, all the characters in the game create an interesting world that makes a game (that is, an emergent story line, as in Pizza Tycoon).
This is implicit design, because the story is not controlled directly by the designer, although each individual NPC behaves as told (low-level explicit control). If the NPCs are intelligent rather than scripted, the designer's control lies in the environment only!
Many games are built in the implicit fashion, but very few of these actually have a story line (for instance, SimCity, Transport Tycoon). The story line is whatever path the player decides to take. In these games, designers can't easily control how the AI comes together to affect the gameplay.
The combination of top-down and bottom-up approaches to game design is a topical problem in AI research. One practical solution that's already been used (in Grand Theft Auto III, for instance) is to alternate sequences of explicit control (to set up the story line), and implicit control (to allow the player to play it). In this case, the behavior of the NPC is overridden during the "cut scenes" and left to autonomous AI control otherwise.
What Conflict?
These distinct types of games reduce the overlap between the AI and the design. In general, the designer's job is to craft the game, from the low-level behaviors to the overall story line. Animating characters is a crucial part of this. It's the AI's responsibility to control the behavior of in-game characters, bringing the vision to life.
Conflict can arise when the designer wants explicit control of an intelligent NPC. In this case, the AI has to perform a particular action in a specific situation as told. This is the easiest problem to resolve—even with standard AI techniques—because the AI can be directly overridden (as in cut scenes).
Further conflict can arise when designers want the story line to emerge in a different fashion (for instance, get the characters to force the player into this situation instead). This cannot be resolved as simply because the control is implicit; there's often no easy way to tell the NPC directly what to do for a particular situation to emerge.
Designers of games with story lines seem to have particular issues with implicit control, not realizing the challenges presented to the AI programmer. Identifying the situation can help. As a rule of thumb, control is implicit when it requires more than one operation to achieve.
For example, making sure that there is another player—any player—behind the door when it opens is explicit control; it's just a matter of spawning a new entity into the game world. However, guaranteeing that teammate Marvin is behind the door when it opens is implicit control. Just moving Marvin would make the game world inconsistent. (He might have been visible at the time.) So he actually needs to go through the door, which takes more than one operation; it's implicit control.
The solution is for designers to agree with the AI programmer upfront about all types of implicit control required, and then to specify explicit control as necessary. The idea is that the AI system needs to be engineered specially to provide "handles" for implicit control, whereas explicit control is just a matter of overriding the system.
Setting up guidelines allows the AI developers to exploit the freedom they are given to build the AI system. Designers will make the most of the AI system with the agreed forms of control—harnessing their power to improve the gameplay.
Ref : By Alex J. Champandard
The State of Game AI
Remember the dawn of 3D graphics in games? Only a few companies were willing to take the plunge: the proverbial penguins. Some mastered the subject, but the games still had many bugs. Visual artifacts slowly disappeared, eventually becoming unacceptable. Nowadays, even when new technologies are introduced, they are integrated seamlessly; the development pipeline is well established. There is much experience in the field, assisted by a strong hardware industry.
In AI, we're still in the first stage. Common techniques that have been used over the years—such as scripted behaviors and A* pathfinding—could be compared to 2D graphics. Although improvements still need to be made, these two techniques have matured tremendously; scripted behaviors and A* pathfinding in most AI systems nowadays don't make obvious mistakes. This is an amazing feat. We've even reached a stage where such AI techniques shine in some games (for instance, Unreal Tournament 2003 and Return to Castle Wolfenstein).
However, AI (both kinds) is set to revolutionize the way we make games. AI technology is modernizing the development, and intelligent creatures are transforming game design.
Technological Revolution
Some companies have ventured into more advanced technology borrowed from the field of AI (for example, decision trees or reinforcement learning). In these applications, the superior AI generally achieves similar design goals, only the means of production change. (For instance, Colin McRae Rally 2 uses learning and neural networks, which means the AI doesn't have to be programmed manually [Hannan01].) Despite the standard gameplay design, the game engine needed to be adapted to accommodate the AI techniques and the development process (usually involving less scripting). This is the technological AI revolution in the trenches.
Nevertheless, a certain amount of skepticism still exists within the game-development community—and justifiably so. Why is better AI technology actually needed? Given a standard design, does it help the development in any way? The answer is that AI techniques are not a requirement per se. There's no need for awesome technology if it produces the same gameplay! In development, we could do fine without AI; in fact, most professional game programmers have the skill to do without any form of AI if they so desire.
However, AI technology has the potential to improve the development process by boosting efficiency, speeding up design and experimentation, and generally improving the quality of the final product—when chosen in the right context. We spend the rest of this book on this subject, learning from successful prototypes and making mistakes.
Design Revolution
Few other games use modern AI to actually push levels of NPC intelligence beyond designs possible with "standard" AI (that is, scripts and pathfinding). Together, the stronger AI techniques and adventurous designs have led to obvious improvements in gameplay. For example, Black & White's gameplay revolves around the interaction with an intelligent creature with learning abilities.
On the whole, these more intelligent creatures have had a great reception from the press and the public (including AI enthusiasts). Capturing this amount of attention has only been possible with ambitious designs, which the game community now seems to crave. This is the AI design revolution, and it's just starting.
There's a calm certainty that a golden age in AI NPC is looming, despite some hesitations about how to make it happen. There is little doubt that the AI revolution will be mainly design driven. The savings generated by a better AI production pipeline compare meekly to the lucrative market for AI games. This market in itself is enough to drive any progress.
The technology to bring these AI designs to life has been available for years—if not decades. Granted, the necessary processing power and experience have been lacking anyway. Only recently has it matured enough; nowadays, practical wisdom has increased dramatically and computational power is less of a problem. In this book, we explore such techniques capable of bringing AI designs to life efficiently.
Ref : By Alex J. Champandard
Computer Games and AI
Computer Games and AI
As mentioned previously, AI means two different things. Which kind of AI do we mean when we say "computer game AI"? What good is AI for computer games?
It's understandable that we want intelligent characters in our games because they add to the experience and improve gameplay. Intelligent NPCs make single-player games possible, and improve multiplayer experience, without having to rely on an existing community of (biological) people.
We want useful sidekicks, worthy deathmatch opponents, hordes of enemies that get shot in particularly entertaining fashion, and background characters that add depth to the game. Regardless of the game type—whether real-time strategy (RTS), first-person shooter (FPS), or massively multiplayer online game—intelligent NPCs are absolutely necessary to create the illusion of playing with other intelligent players.
Fundamentally, these examples revolve around synthetic characters. Because the essence of the problem is to develop a single NPC, that seems an obvious place to start (from an educational point of view). Focusing on one creature leaves vast quantities of processing power available, which provides a perfect test bed for experimentation.
Note
In AI, a smart entity is known as an agent. A system that handles more than one game unit in coordination is known as a multi-agent system. Developing multiple agents involves scaling down the AI enough so that it's feasible to scale up the number of NPCs. In essence, it's about using simpler AI using less memory and processing power—although this is a challenge in its own right!
From an external point of view, NPCs need only to display a certain level of intelligence. This is one key realization; computer game AI requires the result. It doesn't really matter how NPC intelligence is achieved, as long as the creatures in the game appear believable. So AI technology is not justifiable from this outsider's point of view, because standard software engineering techniques could be used equally well to craft the illusion of intelligence (for instance, scripting).
Ref : By Alex J. Champandard