Wednesday, June 4, 2008

Artificial Intelligence (Game Design: Theory and Practice)

Game Design: Theory and Practice (Book's summary: part 8)

Book’s Author: Richard Rouse III

Summarized by Samuel Coelho

7. Artificial Intelligence

In an academic context, artificial intelligence is sometimes defined as a system that can reliably pass on what is called the Turing Test. In the Turing test, humans are presented with computer terminals into which they can type various sentences and can then see responses printed on the screen. If the users believe that the responses were provided by a human, even though they were actually provided by the computer, then the computer would have passed the Turing test and could be said to possess artificial intelligence.

When game developers talk about artificial intelligence, they do not mean the computer’s ability to trick players thinking they are playing against human opponents. Instead, game developers refer to whatever code that is used to control the opponents players battle as artificial intelligence.

In AI research, the end goal is to simulate the human mind. In a game, the ultimate goal is to make sure the game experience is fun.

As with many of the programmers on a development team, the AI programmer needs to have a good game design sense in order for the final AI to be sufficiently challenging, interesting, and entertaining to the player.

As the game’s designer, you want to direct those AI-controlled characters to create the most stimulating experience possible for players.

7.1 Goals of Game AI

Different games provoke different expectations in players of how smart the AI agents in those games need to be. We can construct a general list of goals for any computer game AI, goals that change in importance as the design goals for a given game vary.

7.1.1 Challenge the Player

Providing a reasonable challenge for players must be the primary goal for the AI in any computer game.

The fact that creatures far outnumber the player character tends to compensate for the reality hat none of these creatures is very smart. Thus, AI provide a challenge for players by being more powerful and numerous than the player.

By using AI we intend to challenge the player without appearing too unfair in the process.

It’s important to keep in mind that you don’t want to punish the player too severely with your game’s AI.

7.1.2 Not Do Dumb Things

AI for a computer must not appear overly stupid. To the player, it is completely obvious what the AI should do in most of the situations. But what may look obvious to players can actually be a fairly complex action for the agent to perform or understand. Nonetheless, for the game to avoid becoming a laughingstock, the game’s AI must have a solid mastery of what seems obvious to human players.

The number of dumb things the AI will be able to get away with has a direct relationship to what sort of intelligence the AI is supposed to represent.

AI stupidity is also acceptable relative to the type of world the computer game is supposed to create.

7.1.3 Be Unpredictable

Since you cannot provide the social component of multi-player games, you can at least strive to make the AI agents provide much of the same challenge and unpredictability that is provided by a human opponent.

Players will keep playing the game until it no longer provides them with a challenge, until they no longer experience anything new from playing the game. An AI that can keep surprising them, and thereby challenging them, will keep their interest high.

“Fuzzy logic” is one method AI designers and programmers may use to keep the AI agents unpredictable and interesting. Essentially, fuzzy logic takes a logical system and inserts some randomness into it. In fuzzy logic, when the AI is presented with a given situation, it has several worthwhile courses of action to choose from instead of just one. Say that players are at a certain distance with a certain weapon while the AI agent is at a certain health level and is equipped with a certain type of weaponry. There may be three reasonable things for the agent to do in this case, and each can have different numerical values or “weights” representing their relative quality. Say that running up and attacking the player character makes a lot of sense, so it rates as 5. Doing a threat display in order to frighten the player makes a bit of sense, so it rates as 2. And maybe trying to circle around the player character in order to disorient him is also plausible, so it rates as 3. Using these different weights, the agent can simply randomly pick a number from 1 to 10 (the total of the weights). If less than or equal to 5, the agent will run up and attack. If 6 or 7, the agent will try to frighten the player, and if 8 through 10, the agent will do it’s best to disorient the player.

Basing AI decisions on randomness makes the agent look like it is performing complex reasoning when it’s not.

Of course, the unpredictability of an AI agent in a game must no conflict with the other AI goals. If an agent is so busy being unpredictable that it cannot put together a solid plan of attack against the player, it is not going to be much of a threat to players and they will not be challenged.

7.1.4 Assist Storytelling

Game AI can be used to further a game’s story. For example, in an RPG, players may travel to a certain town that is home to a number of fearful residents who dread the arrival of outsiders. If players only observe these people, they can be seen to be navigating the town, going to the stores, restaurants, and factories just as people in a real town would. This sets the scene for the town and makes it seem real to players. But whenever players approach these people, they turn away, fleeing to safe areas to avoid interacting with the players.

One area where AI is often avoided entirely by designers but where it can be quite useful is in dynamic storytelling. All too often designers cobble a story around a game instead of integrating the story with the gameplay.

Why not be able to affect the mood of the different NPCs players encounter?

Instead of telling static stories, we could be telling ones that tough not entirely procedurally generated, were subtly different depending on how players played the game.

7.1.5 Create a Living World

Adding ambient life to a world can do a lot to make the game-world seem more real to the player.

A game-world may be infinitely detailed in terms of the objects it contains and how it looks and sounds, but players are used to a real-world that also contains living organisms that think for themselves and behave in interesting ways.

Players love to see that the world has ambient life in it, creatures they can just look at rather than kill, and the depth it adds to the world can be invaluable.

7.2 The Sloped Playing Field


The goal of game AI is to support the game and enhance players experiences, not to serve as a test-bed for artificial intelligence techniques.

Just as the Hollywood action hero triumphs over countless foes, players want to overcome seemingly insurmountable odds for their own victories.

7.2.1 How Real Is Too Real?

Games are often contrivances, strictly unreal situations that are specifically set up because they are interesting, not because they are authentic, and the AI must support this.

If the enemy AI is so smart, surely it should realize that it has no chance against the player and should lock itself away in a safe bunker, refusing to open the door to anyone. :P

The point again is that the AI must never overshadow the gameplay, and it must never distract the development team from the true goal of the project: to make a fun, playable game. If the AI is really very sophisticated but, as a result, the game is unplayable or extremely frustrating, players are not going to remark on the intelligence of the game’s combatants. AI and gameplay are too closely entwined for one to succeed if the other fails.

7.3 AI Agents and Their Environment

For a game AI to turn out well, it needs to be developed in close association with the game’s gameplay and the environments in which that gameplay is going to take place.

The best one can hope for is that the AI has a fighting chance in a specific type of gameplay situation. If the level and the AI are not developed synchronously, then there’s little chance that the opponents the players face will appear very smart at all.

Try to make a simple playable AI first. It does not need to be bug free or work perfectly in every situation. If it works fairly well in some situations, level designers can start making levels that facilitate what the AI is known to do well.

The design of the levels may give the AI programmer new ideas about what tricks the AI can pull off.

If the AI programmer can then add functionality to identify some particular locations and behave accordingly, the AI will become stronger as a result.

Both sides of the designer/programmer equation must be ready to compromise. Often a designer may have to compromise for the good of the project, modifying something he may like but which horribly confuses the AI. Similarly, the programmer may need to add some ugly special-case code to accommodate a problem that occurs in a majority of the maps that have been created.

The designer and the programmer must trust each other such that when one of them tells the other something needs to change, they believe the other and make it happen.

7.4 How Good Is Good Enough

The AI sophistication a game requires is dependent on how much the failure of that AI will impact the player. If the AI screws up and the player’s game ends as a result, that is very bad. If the AI makes mistakes and the only consequence is that the player’s game gets slightly easier, then it’s a failing that players can probably live with, as long as it is a rare enough occurrence.

It would be nice to make every system in a game as smart as possible, but the realities of the production cycle dictate that there is only so much time that can be invested in any given part of a game. Rare is the case that a programmer has finished all of the work needed for a game and still has time to “polish” everything that he would like. As such, spending a lot of time on overly sophisticated AI systems will directly take time away from other tasks that desperately need work.

Humans when presented with some seemingly random data will try to make sense of it, to put it into order, and to try to find meaning where there may, in fact be none. By throwing in some random behavior, your AI agents may come out looking smarter than they really are.

7.5 Scripting

Scripted behavior should be used just to give the AI agent hints as to where good locations to duck and cover might be.

In some games, a combination of dynamic AI with predetermined paths and scripted and scripted behaviors may create the most exciting experience possible for the player.

Setting up scripted behaviors that are specific to a level is very much the concern of the level designer. With scripted behaviors the designer needs to repeatedly play an area to figure out the most devilish places for the AI to hide, where it should retreat to when low on health, and how it should best reposition to have the greatest chance of defeating the player.

The AI must be able to realize when the scripted behavior is not working out and when to try an unscripted, more general behavior.

1 comment:

Anonymous said...

makine santranç oynuyo