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.

Tuesday, June 3, 2008

Game Analysis: Tetris (Game Design: Theory and Practice)

Game Design: Theory and Practice (Book's Summary: Part 7)

Book’s Author: Richard Rouse III

Summarized by Samuel Coelho

6. Game Analysis: Tetris

Game developers, the press, and developers alike tend to resent games for its sales, but what is about Tetris that makes the game immune to criticism? It would appear something about the game’s simplicity and clearness of design vision that makes even the most cynical game developer concede the game’s greatness.

Gameplay in Tetris is exceedingly uncomplicated. The game-world is a tall, rectangular, 2D box. Blocks appear at the top of the box. The blocks are made up of four squares arranged in every possible pattern where all squares share at least one side with another square. The blocks then slowly fall to the bottom of the box, and players are able to move these blocks to the ledt and right, or rotate the piece in 90 degrees increments. Once the block hits an obstruction, either the bottom of the box or another piece, the block stops moving. Players lose control of the block, and another piece that players can now control appears at the top of the screen. When the blocks at the bottom of the screen form a horizontal line across the rectangle, that line of squeres disappears, and any squares above that line move down one row. As gameplay progresses, the speed at which these blocks fall from the top of the screen increases, thus increasing the challenge for players and ramping up the difficulty over the course of the game. The player’s game is over once incomplete rows of the blocks fill up the game-world rectangle and subsequent pieces are prevented from entering the play-field.

Everyone who plays Tetris, each time they play it, has a unique experience. Players can always find ways to improve their Tetris playing ability. This is a crucial difference between Tetris and a traditional puzzle. Once players have solved a puzzle, if they remember how they did it the first time, the puzzle will no longer present any challenge to them.

6.1 Puzzle Game or Action Game?

One action game mechanic Tetris uses is the sense of an ever-approaching threat that players have to address in a limited amount of time. Players constantly have to consider where the future blocks will or will not be able to fit. Players may learn to recognize certain pieces of configurations, but every game is sufficiently unique that no players can be completely prepared for the challenges that may face.

6.2 Tetris as a Classic Arcade Game

Despite the fact that Tetris wasn’t originally conceived for gameplay in arcades, there are many traits from arcade games’s design principles in it that let us classify it as an arcade game. These traits are: single screen play, infinite play, scoring/high scores, simple gameplay, and having no story.

There is no exploration component to the game, no way to really surprise players (beyond what piece appears next), so players have all information they need to be successful at the game, and have nothing to blame but themselves for failure.

The achieving of a higher score make players want to play the game again.

Players will need only three buttons in order to play Tetris. Thus, anyone, regardless of how familiar they are with computer games, can walk up to the game and start playing it immediately.

6.3 The Technology

Tetris’s gameplay is so strong that it does not matter how technologically simple its implementation may be, the game is still wildly entertaining.

The implementation of Tetris is so simple that many aspiring game programmers start out by making a Tetris clone.

Tetris knockoffs attempted to make “improvements” on the original, either through fancy effects or special pieces of various sorts. None of these attempts were particularly successful, and players continued to want to return to the original.

Enhanced technology is not necessarily beneficial to a given game, and game designers must be wary when the whizbang engine effects start to get in the way of what makes the game entertaining in the first place.

6.4 Artificial Intelligence

Tetris artificial intelligence randomly picks the blocks which fall into the play-field.

The fact that a random number generator provides all the challenges in Tetris demonstrates an important point. The AI the players face only needs to be as smart as the game mechanics require.

6.5 Escalating Tension

Tetris is very ruthless in the way it escalates tension throughout the game. The game’s tension escalates as a result of the plauyer’s mistakes. The only reprieve players find in Tetris is when they “battle their way back” from a trick situation.

Further escalating the game’s tension in the acceleration of the speed at which the pieces fall over the course of the game. When player’s score increases above certain amounts, the pieces in the course of the game start moving at a faste rate, which makes the game nerve-racking for the players.

Further complicating matters are the bonus points players receive for removing four rows all at once with an “I” piece. With this tactic, the game tempts players into taking potentially game-ending risks.


6.6 Simplicity and Symmetry

All of the pieces in Tetris are composed of four squares, each of which shares at least one side with another square. This gives the game an inherent consistency and balance.

At some point a complexity level begins to stifle the core nature of a game and confuses players instead of challenging them. It would appear Tetris expertly follows the adage that everything should be as simple as possible but no simpler.

Part of what makes Tetris so elegant is the completeness of its pieces. Every possible permutation of four squares with squares sharing sides is used in the game.

When playing, players will find themselves presented with many situations that cry for certain pieces. The natural completeness and symmetry of the pieces available to players in Tetris is a crucial component if its balance.

Monday, June 2, 2008

The Elements of Gameplay (Game Design: Theory and Practice)

Game Design – Theory and Practice (Book's Summary: Part 6)

Book’s Author: Richard Rouse III

Summarized by Samuel Coelho


5. The Elements of Gameplay

This section discusses what elements in a game make this game great from the author’s viewpoint. Amidst these elements are: non-linearity, modeling reality, unique solutions, and input/output (Sorry for the pic... :P).

5.1 Unique Solutions

Games can be viewed as situations in which game players can utilize their own creativity to succeed.

5.1.1 Anticipatory versus Complex Systems

Good designers will try to guess what players are going to attempt to do and make certain their game responds well to those actions.

With a more holistic system for the game, it becomes more like a simulation. The more designers recognize the value of simulations over hard coding and emphasize these complex and interconnected systems in their games, the deeper their games can become.

5.1.2 Emergence

Establishing a game universe that functions in accordance with logical rules players can easily understand and use to their advantage allows those same players to come up with their own solutions to the problems the game presents.

The more complex systems work correctly and concurrently with each other, the more interesting and varied the solutions to situations become.

At the same time, many designers fear players discovering emergent strategies they can use as exploits: tactics that will allow players to finish a game too easily, skipping a lot of the fun. These tactics reveal a shortcut through the game that needs to be fixed.

Though some designers become distressed whenever an unanticipated strategy emerges in their game, it is important to look at the given tactic and determine if it ruins the player’s experience or if it is a technique equally or even more fun than what the designer had planned.

5.2 Non-Linearity

Games are meant to be non-linear works. In the game of chess for example, there are multiple ways to capture the opponent’s king, to move from the game’s predetermined starting state to its conclusion. There are a vast number of different ways to be victorious in chess, and that variety is what keeps the game interesting.

Thus, we want to provide choices for players to make, different paths they can take to get from point A to point B, from the game’s beginning to its end.

The different non-linear components can interact with each other to make the whole far greater than the sum of its parts.

Having multiple solutions to the individual challenges within a game is a big part of non-linearity.

Many adventure games have made the mistake of being overly linear by allowing players access to only one puzzle at a given time.

Giving players a choice of which challenges they take on allows them to exploit their own personal skills to get through the game.

If you want to have multiple solutions or paths, they should all be equally compelling so players will not feel cheated at having picked the much less spectacular path.

Designing numerous obstacles that are different enough to provide variety for players and apply roughly the same challenge is not an easy task. If you have the challenges X, Y, and Z, and Z is significantly easier than X or Y, it is quite likely no one will ever bother with X or Y. In a way, a game with poorly designed choices for players is nearly as linear as a game without any choices at all.

5.2.1 The Purpose of Non-Linearity

All designers should understand that non-linearity is not about having players wander around the game world aimlessly. If the game is non-linear to the point where players have no idea what they are supposed to try to accomplish or how they might go about it, the non-linearity may have gone too far.

Noah Falstein suggested that when non-linearity allows players to tackle a series of problems in whatever order they desire, completing one challenge should make the others easier for players to accomplish. In the case of a collection of puzzles, this can be done by providing players with a hint about the other puzzles once one is completed. In the case of a collection of battles of some sort, this can be done by providing players with additional weaponry with which to survive the other battles.

It is important to always remember that non-linearity is included in the game to provide players some meaningful authorship in the way they play the game.

It’s also important to note that replayability is not the main motivation for including non-linearity in your game designs. The main reason for us to implement non-linearity is to give players a sense of freedom in the game-world, to let players have a unique playing experience, to tell their own story.

5.3 Modeling Reality

The trouble with modeling reality games comes when titles get mired in reality to the point where they come to resemble real life a little more than players want. Games should be modeling life or some aspects of life while leaving out the tedious and boring parts.

Using reality as a basis for your games also has its advantages. Players will understand or at least think that they can understand what they can do to be successful in the game-world.

In Terms of story and setting, placing your game in a real-world setting can be much more meaningful to players, allowing the actions that take place in the game-world to resonate with them more deeply than if your game were set in abstract worlds.

A potential downside to having a realistic world is that, since the game mimics a reality players are familiar with, players will expect certain game-world elements to work in certain ways and will be very quick to notice when something fails to do so.

Players only want more realism if that means that they can do more interesting and fun things, not if it makes their game experience more frustrating.

As a game designer you must strike the balance between reality and abstraction, weighing what your game needs from a gameplay standpoint with what your story and setting require and with what your engine can reasonably handle.

5.4 Teaching the Player

The first few minutes the players will spend with your game will often make the difference between whether they want to continue playing it or not.

If your game is too difficult to get a handle on within the first minute, players are most likely to put it down and try something else.

This does not mean that your game must be dumbed down or simplified, merely that you must introduce the complexity of your game-world gradually through the gameplay instead of through the manual.

It’s important that during the introduction of the game controls players are in a safe environment that engenders learning.

It’s important to reward players even for the simplest of accomplishments. This makes players feel that, indeed, they are on the right track with the game and encourages them to keep playing.

5.4.1 Tutorials

The tutorial levels do one of the things that computers do best: provide an interactive learning experience. These levels tend to lead players by the hand through the game’s mechanics, teaching them what they will need to know bit by bit. Some players, typically females, tend to prefer actually being led through the game for a bit until they get the hang of it, and structured tutorial levels are perfect for this.

The one problem with tutorials is that they are seldom much fun to play, and as a result many players will skip them and head straight for the actual game.

Beyond the learn of controls, there is often little interest in tutorials. There is a feeling among the players that the tutorial level is not part of the “real” game, and many players want to start playing this “real” game as soon as possible.

5.5 Input/Output

Designing input and output systems is an “invisible” art in that the goal of their creation is for them to be transparent to players. This can sometimes lead designers failing to fully consider how to best make the I/O work in their game, a mistake you must avoid if you want your games to be any fun to play.

By the use of the input/output system that you design, players must be able to control and understand the game effortlessly.

5.5.1 Controls and Input

The controls are the player’s interface between the real-world and the game-world. In order for players to experience true immersion in the game they must be able to manipulate the game-world almost as intuitively as they manipulate the real-world. Every time players have to think, “Now, what the button do I have to press to do that?” that immersion is destroyed.

The mouse is an extremely powerful device when used correctly. Its great strength is that it is a control device which most non-gamer computer users are already familiar with.

Whenever an artist suggest to make a button for GUI look a certain way, the designer must consider if the new design takes away from the player’s ability to understand how that button works.

Every time you need to add a new button or key to your game, you must ask yourself if the complexity you have just added to the game’s controls is worth the functionality it enables.

Because of the massive keyboard at their disposal, designers for PC games are not forced to focus on controls of their games in the same way that designers working on a game for consoles do, and think their games might not suffer for it.

One technique that can be used to make your controls intuitive to a variety of playersis is to include multiple ways to achieve the same effect.

There is a lot of room for creativity in game design, but control design is not one of the best areas to exercise your creative urgencies. Your game should be creative in its gameplay, story line, and other content, but not necessarily in its controls. Some of the most successful games have taken control schemes that players are already familiar with from other games and applied them to new and compelling content.

Console games are particularly good at providing uniform control schemes, with fans of games in a particular genre able to pick up and immediately start playing almost any game available in the genre, even if they have never seen it before.

During the course of the development of a game, as you are playing the game over and over again, it is very easy to get accustomed to bad controls. Though the controls may be poorly laid out or counterintuitive, as a game’s designer working on a project for several years, you may have used the controls so much that they become second nature.

Always make sure the default controls are as intuitive as possible, and if it this involves shameless imitation, so be it. Many players never find or use the control configuration screens, either because of the desire to start playing the game immediately or a general lack of savvy with the computer. After you get them so you like them, you must put them in front of players to see how well they work in practice instead of theory.

Particularly in action games, when your controls are perfect, the wall separating players from the game-world will disappear and they will start to feel like they truly are the same game-world character. This is the ultimate sign of an immersive game, and achieving this effect is impossible without strong controls.

5.5.2 Output and Game-World Feedback


While the player’s ability to intuitively control the game-world may be the key to a successful game, outputting that vital information about the game-world to player is just as important.

A good output system for a game is both powerful and intuitive. It allows players to jump right into the game and understand what is happening in the game-world, but it also provides expert players with all the information they need to play the game effectively.

All computer games conceal a certain amount of information from players, and cannot possibly communicate all of the information they have about the game-world to players. But they must communicate what is reasonable and important for players to know, and communicate that data effectively.

Almost all games present players with a view of the game-world as the central part of their output system. Through this view players see the object they are currently controlling and its location and state in the game-world.

Though the designer may also want to include data in heads up display (HUD), communicating it through the game’s primary game-world view makes it that much more transparent and easy for players to understand.

A well-designed graphical HUD in your game will be easier for players to glance at and understand than one that contains a lot of numbers and words. This explains the superiority of the health bar over a health number of percentage.

Certainly, as technology has allowed it, the trend has been to get away from the on-screen HUD’s as much as possible, allowing the game-world view to take over the screen if
The game-world can effectively communicate all of the information the players need to play.

The GUI for your game needs to balance the superiority of t visual representation with the clarity of text, possibly using a combination of both as needed.

Audio cues can provide an excellent supplement to on-screen information, or can work quite effectively as the sole way of communicating critical information.