Title: Technical Issues: Artificial Intelligence
1Technical IssuesArtificial Intelligence
2Technical Issues Artificial Intelligence
- Artificial intelligence can mean a variety of
different things in different contexts. - By purist definitions, a game would possess
artificial intelligence if a game player cannot
distinguish between characters controlled by a
human, or by the game itself. - In such a case, the game would be passing a
limited version of what is called the Turing
test. - In actual practice, however, a game that does not
pass this test still has artificial intelligence,
just not really good artificial intelligence.
3Technical Issues Artificial Intelligence
Screen shot from Unreal Tournament 2003. If you
cannot tell if an opponent or teammate is a
human or a bot, then the bots artificialintellig
ence has passed the Turing test.
4Technical Issues Artificial Intelligence
- Game developers rarely use the Turing test
definition of artificial intelligence. - In a game, artificial intelligence refers to the
code used to control all non player characters
and opponents within a game. - The reactions of the game may be totally random,
or totally logical, but the control code is still
referred to as the artificial intelligence of the
game.
5Technical Issues Artificial Intelligence
Even though the opponent control for Centipede
(left) and block droppercode for Tetris (right)
is simple and scripted, with a random
number generator producing some variation, both
are still considered to posses a certain amount
of artificial intelligence.
6Goals of Game Artificial Intelligence
- Players have different expectations of the
artificial intelligence they find in different
types of games. - Some games, like Centipede and Tetris, have very
minimal intelligence requirements. - Other games, however, are heavily dependent on
good artificial intelligence. If it is weak, the
game would simply not be worth playing. - Despite this, there are several general goals for
any game artificial intelligence. The importance
of these goals depends greatly on the game.
7Goals of Game Artificial Intelligence
Screen shot from CompuChess. Without strong
artificial intelligence, a game of chess might
not be worth playing, except for beginners.
8Goals of Game AIChallenge the Player
- Providing a reasonable challenge for the player
must be the primary goal for artificial
intelligence in any game. - There are several ways to provide challenge
- A very sophisticated artificial intelligence.
- Outnumbering the player.
- Giving opponents abilities and advantages that
the player does not have. - Assigning the players teammates or additional
obligations that might hold them back. - Cheating. (As long as you dont get caught!)
- Poor game design. (Do not do this!!!)
9Goals of Game AIChallenge the Player
Screen shot from Doom II. It created challenges
for players by vastlyoutnumbering the player,
and providing opponents many advantages
(unlimited ammunition, seeing in the dark,
flying, and so on).
10Goals of Game AIChallenge the Player
Screen shot from Warcraft III. Sometimes, the
difficulty in selecting and controlling units in
the heat of battle provides an unwanted and
frustrating challenge.
11Goals of Game AIChallenge the Player
- Creating a challenging and sophisticated
artificial intelligence can be quite difficult. - In some games, outnumbering the player and
providing additional abilities is not what the
player wants or expects. - In such cases, the artificial intelligence must
be very good. - Depending on the game genre and game
characteristics, the player must be challenged in
different ways.
12Goals of Game AIChallenge the Player
Screen shot from NHL 2003. It would break player
expectations by giving opponents extra abilities
or by outnumbering the player. The
artificial intelligence must be better to
compensate for this.
13Goals of Game AIChallenge the Player
Screen shot from Alpha Centauri. Since it is a
strategy game, the player expects a strong
opponent as the game is very thought intensive.
Since thegame is turn based, the game cannot
overwhelm the player by processing alone the
player can take their time and think.
14Goals of Game AIBe Realistic
- A game should provide artificial intelligence
that is appropriate to its setting, story, and
characters. - Characters that are supposed to be smart should
not do dumb things. - Characters that are supposed to be dumb should
not do smart things. - The more human and realistic a character is, the
smarter it should behave. - Beast-like, alien, robotic, and undead characters
can get away with more stupid actions, depending
on the situation.
15Goals of Game AIBe Realistic
Screen shot from Quake. The Zombies behave
pretty much as one would expect they lumber
towards you and take your shots until they get
close enough for an attack. Unless they are
blown to bits, they willget up and come back for
more, just like real zombies!
16Goals of Game AIBe Realistic
- There are some things, however, that are so dumb
that nothing should do it. - For example, walking off of a cliff or not being
able to navigate around a small obstacle. - In these situations it is obvious to the player
what the artificial intelligence should have
done. - Unfortunately, players seldom recognize how
complex or difficult such obvious actions are to
recognize and perform. - To avoid ridicule, the games artificial
intelligence must have a mastery of what is
obvious to human players.
17Goals of Game AIBe Realistic
Screen shot from Quake. The ogre was notorious
for getting stuck in doorways in many levels
with its chainsaw, and not knowing how to get
unstuck.To players, this seemed ridiculous, even
for an ogre.
18Goals of Game AIBe Realistic
Screen shot from Oni. In this situation, Konoko
is being chased by Muro. A TCF officer on
Konokos side has beaten his enemy in the
background,and stands over her body for several
minutes. Why isnt he helping me?
19Goals of Game AIBe Realistic
Screen shot from New World Order. Unlike most
games, the AI enemies in thisgame do not have
the benefit of infinite ammunition (for realism,
I guess). When they run out, theyll just follow
you around (for no apparent reason),until you
tire of their company and end their misery. Who
thought that up?
20Goals of Game AIBe Realistic
Screen shot from Counter-Strike. In the Xbox
version, there is a singleplayer mode with AI
bots for team mates and enemies. When these
eliteterrorists and counter-terrorists fail to
navigate even the simplest ofobstacles, it
totally breaks immersion in the game.
21Goals of Game AIBe Realistic
- One must be careful, however, to not make
artificial intelligence too realistic. - Games are often unreal situations set up because
they are interesting, not because they are
authentic. - For example, if an opponent realizes it has no
chance of winning, it should run away
indefinitely, which quickly ceases to be fun. - In building good artificial intelligence, one
must keep in mind the true goal of the project
building a fun, playable game.
22Goals of Game AIBe Realistic
Screen shot from Metaltech Battledrome. A
fairly decent game in its day withincredibly
annoying AI. When the AI had no chance of
winning, it would runaway indefinitely. Chasing
down a weaponless mech for an hour to finishit
off is absolutely, positively, not fun! (I speak
from experience )
23Goals of Game AIBe Realistic
Screen shot from 007 Nightfire. Realistically,
the villain should just killJames Bond and be
done with it, instead of toying around with
him. That wouldnt make for a very good game
though!
24Goals of Game AIBe Unpredictable
- Humans are unpredictable. This is part of what
makes them good opponents. - The same should be true of the artificial
intelligence opponents in a game. - Players want the artificial intelligence to
surprise them and use strategies and techniques
that are unanticipated. - If the player can predict with some measure of
certainty what the game will do, the fun in the
game quickly disappears.
25Goals of Game AIBe Unpredictable
Screen shot from Starcraft. Strategy games
benefit greatly fromunpredictability. It does
not take long for a seasoned player to
recognize the same strategy over and over again.
26Goals of Game AIBe Unpredictable
- Successful unpredictability can take many forms,
depending on the game. - Usually, this involves adding some element of
randomness to the games artificial intelligence. - Could be pure randomness.
- Could be a form of selection in which there are
several valid choices of action that are chosen
from randomly. Weights can be applied to vary
the amount of randomness. - In the end, the player will never know the action
was random, and will tend to attribute it to some
intelligence with a purpose.
27Goals of Game AIBe Unpredictable
Screen shot from Unreal Tournament 2003.
Opponents can act inan unpredictable fashion
through randomly selecting a weapon to use,and
use tactics appropriate to that weapon.
28Goals of Game AIBe Unpredictable
- Keep in mind that unpredictability should enhance
the challenge presented by the artificial
intelligence in a game. - If things are so random that the game cannot put
together a solid plan for defeating the player,
you have gone too far. - Make sure that random choices are still realistic
given the scenario. - If an opponent is about to win, and its
artificial intelligence randomly selects a poor
action, this will seem ridiculous.
29Goals of Game AIAssist Storytelling
- The artificial intelligence in non player
characters can be used for storytelling in many
ways. - Setting mood.
- Advancing the plot.
- Providing foreshadowing.
- And so on.
- By telling the story in the game, as opposed to
just cut scenes, the player becomes much more
involved.
30Goals of Game AIAssist Storytelling
Screen shot from Oni. Konoko has just been
declared a rogue agent, and civilians encountered
reflect this to help establish setting and mood.
31Goals of Game AICreate a Living World
- Creating a sterile game world filled with
inanimate objects is not going to be a very
authenticate reality for the player. - Instead, adding ambient life to a world can do a
lot to enhance the experience. - Can be people going about doing their daily
business. - Can be birds flying in the sky, or animals or
other critters roaming around the ground.
32Goals of Game AICreate a Living World
Screen shot from Grand Theft Auto III. This
series of games always had avery lively city,
full of motorists and pedestrians with
interestingbehaviours. Too bad for them!
33Goals of Game AICreate a Living World
Screen shot from the Legend of Zelda The Ocarina
of Time. The world is full of lively artificial
intelligence agents, including the characters
wandering around, animals, and so on.
34Goals of Game AICreate a Living World
These artificial intelligence agents can be
interacted with in a variety of ways. This is
what happens if you attack poultry too often
death by chickens!!!
35Goals of Game AIPutting It All Together
Movie from Far Cry, built on the Crytek Engine.
It exemplifies a lotof the goals of good game AI
in action.
36Goals of Game AIPutting It All Together
Video from Devastation (courtesy of TechTVs
X-Play). A good exampleof video game AI put
together the wrong way. Big time.
37Artificial Intelligence Tips
- Before looking at some of the various techniques
employed by artificial intelligence designers and
coders, we first provide some general tips. - Some of these are common sense.
- Others have come from years of experience, both
good and bad. - Unless you have a good reason, it is advisable to
follow these suggestions!
38Artificial Intelligence TipsDo Your Homework
- There is no one size fits all artificial
intelligence system. - Different techniques are appropriate for
different situations. - The right solution depends on many factors
- The emphasis of AI in the game.
- The scheduling and budget for AI development.
- The development team make-up and experience.
- It is important to determine the needs of your
game and the capabilities of your team.
39Artificial Intelligence TipsThe Sloped Playing
Field
- It is generally not advisable to pin all your
hopes on creating an artificial intelligence that
can compete with human players relying solely on
its synthetic intellect alone. - Generally, your artificial intelligence will
require an edge to compete with a human player. - By outnumbering the player.
- By having superior strength or abilities.
- By having additional resources at its disposal.
- By having perfect knowledge of the game world.
- And so on.
40Artificial Intelligence TipsThe Sloped Playing
Field
Screen shot from Doom II. It makes use of a
sloped playing field by vastlyoutnumbering the
player, and providing opponents many advantages
(unlimited ammunition, seeing in the dark,
flying, and so on).
41Artificial Intelligence TipsUse the Environment
Wisely
- Tune the design of levels to fit limitations of
the artificial intelligence, instead of the other
way around. - It is incredibly difficult to build artificial
intelligence that can handle every level design
in an effective and efficient manner. - Levels can be worked to fit with artificial
intelligence limitations much easier and with few
or no compromises. - Your non player characters and levels have to
work together to make a game fun to play.
42Artificial Intelligence TipsUse the Environment
Wisely
Screen shot from Damage Incorporated. Players
had to direct teammatesthrough a 3D environment.
Levels had to be redesigned many times
beforerelease because of artificial intelligence
problems in navigation.
43Artificial Intelligence TipsUse the Environment
Wisely
- Put smarts into the game environment itself, in
addition to the characters. - Have objects in the world announce themselves to
non player characters and provide them
information and scripts on how to use them. - Embed navigation information in level design so
that characters can traverse levels more easily. - By making a smarter environment, the artificial
intelligence driving characters does not need to
be as sophisticated. - Characters do not need to locate or identify
objects or terrain they broadcast and tell them
instead.
44Artificial Intelligence TipsUse the Environment
Wisely
Screen shot from The Sims. The Sims makes use of
smart terrain thatbroadcasts what it offers.
For example, the refrigerator broadcasts that it
cansatisfy the hunger need and tells Sims how to
use it to do so when needed.
45Artificial Intelligence TipsKeep it Simple
- In the rush to beef up the artificial
intelligence in a game, it is very easy for it to
get out of control and too complex. - Ideally, the AI system should let the developers
do complex things with a variety of simple parts. - By combining the simple parts appropriately, a
variety of interesting and complex behaviours
can be provided. - By keeping things simple, the system will be
easier to understand, reuse, debug, and maintain.
46Artificial Intelligence TipsPrecomputation is
Good
- Good artificial intelligence can be
computationally expensive at run-time. - Scarce resources are also needed for graphics,
animation, physics, networking, and other
subsystems though. - Precomputation should be used wherever possible
to provide good AI cheaply. - Scripting of sequences of actions.
- Navigation through game terrain.
- Collisions with obstacles.
47Artificial Intelligence TipsPrecomputation is
Good
Screen shot from Thief II. This game uses
navigation meshes to help characters navigate
terrain. By precomputing these in advance, and
usingthem in level design, character artificial
intelligence is simpler and cheaper.
48Artificial Intelligence TipsTimeouts and
Fallbacks
- Nothing looks worse than an artificial
intelligence that repeatedly does the wrong thing
over and over. - Players will not notice them make a wrong turn,
but they will notice continuous collisions with
an easy to navigate obstacle. - Every artificial intelligence system should check
for success conditions within a reasonable amount
of time. - If a timeout occurs, the system should give up
and try something different. - At a minimum, it can fall back to interesting
idle animations that express its confusion or
frustration while a new plan is formulated in the
background.
49Artificial Intelligence TipsTimeouts and
Fallbacks
Screen shot from Grand Theft Auto. Police were
notoriously bad at moving around stopped
vehicles to arrest the player they could easily
get stuck or run back and forth. Timing out and
falling back would have been good.
50Artificial Intelligence TipsAvoid Story
Interference
- If the artificial intelligence in a game
interferes with its story, it must be fixed. - The artificial intelligence system must be aware
of game events that are important to telling the
story. - This includes conversations, listening to dialog,
watching a cut-scene, and solving game puzzles. - The AI system should know it should back off and
not get in the way.
51Artificial Intelligence TipsAvoid Story
Interference
Screen shot from Oni. Konoko was having a
conversation with the scientist inthe lab coat
when she was viciously interrupted.
Unfortunately, she missedthe rest of the story.
The guard was punished appropriately.
52Artificial Intelligence TipsProvide Memories
- The artificial intelligence characters in a game
should remember what has happened to them and
others during a game. - They can then change their behaviour and dialog
accordingly. - This gives the player a sense that they are
living beings with thoughts and feelings. - If the artificial intelligence in a game can
learn and adapt from its memories of events, so
much the better.
53Artificial Intelligence TipsProvide Memories
Screen shot from Quake 3 Arena. Most game
characters and bots havememories. If you shoot
them and get on their bad side, they rememberit.
They will even keep grudges against each other
too!
54Artificial Intelligence TipsVariety Through Data
- A variety of character behaviours keeps games
interesting and entertaining. - Providing code for each behaviour introduces
programming, debugging, and testing headaches. - Instead, code should provide one or a small
handful of behaviours that are greatly
customizable through data. - Designers can then introduce a new behaviour by
tuning these variables. - This includes awareness, speed, tactics, weapon
preference, field and range of view, inventory,
strength, abilities, chatter, and so on. - This data should be available to designers to
assist in game balancing and adjustments.
55Artificial Intelligence TipsVariety Through Data
Screen shot from Unreal Tournament. It provides
a wide variety of bot behaviours based on the
settings of a few parameters.
56Artificial Intelligence TipsSolve the Right
Problem
- Solving a different problem from the one thought
to be at hand could result in a superior
solution. - Always ask yourself
- What is the real problem we are trying to solve?
- Can I solve a different problem that is easier or
cheaper and get a result that is equivalent or
superior? - This process can be difficult but can also be
very rewarding in the end. - It takes time and practice to do this effectively.
57Artificial Intelligence TipsSolve the Right
Problem
Screen shot from The Sims. To solve one problem
(How can Sims locate and identify game objects
to satisfy their needs?), Will Wright actually
solved the real problem (How do I get the Sims
to behave intelligently?).
58Artificial Intelligence TipsSolve the Right
Problem
Screen shot from NBA Live 2004. EA Sports went
for a new five player teammotion capture, to
grab all players activities at once. This was
intended toprovide a better look to the game,
but at the same time, it gave the AI
betterreactions to player actions essentially
motion capture made the AI smarter!
59Techniques for Artificial Intelligence in Games
- There are many different techniques used for
providing artificial intelligencein games. - Most techniques come from mainstream work in
artificial intelligence. - These techniques typically include
- Search techniques
- Rule based systems (finite state machines,
decision trees, and production rule systems) - Game theory and game trees
60Techniques for Artificial Intelligence in Games
- Techniques used also include
- Artificial life and flocking techniques
- Planning techniques
- Fuzzy logic
- Scripting
- There are many other mainstream approaches that
are not used in practice very much yet, but that
is changing. - This includes neural networks, genetic
algorithms, belief networks, and so on.
61Search Techniques
- Search techniques are used to serve a variety of
functions in game artificial intelligence. - Navigation and pathfinding.
- Constructing action plans (more later).
- And so on.
- These techniques are suitable for both
- Non player character control.
- Control of player characters not being directly
controlled by the player themselves.
62Search Techniques
Screen shot from Starcraft. Starcraft requires
navigation and pathfinding for directing both
player and non player characters around game
levels.
63Search Techniques Navigation without Obstacles
- Without obstacles, navigation is a simple matter
of determining which direction you need to go in
to reach your objective. - Some simple algebra will do the trick.
- If your movement directions are limited, pick the
closest to the calculated result.
y
Start (x1,y1)
Goal (x2,y2)
x
Direction (x2-x1,y2-y1)
64Search Techniques Navigation without Obstacles
Screen shot from Double Dragon. Navigation in
this case can be quite simple,as there are no
obstacles for non player characters to avoid.
They just needto home in on the player and
attack. (In later levels, there are
obstacles,but it is obvious that the AI did
little or no pathfinding around them!)
65Search Techniques Navigation without Obstacles
- The same approach can also be used for aiming the
shots of projectile weapons. - With this however, you would also want to
compensate for - Motion of the target (velocity and acceleration)
- Motion of the shooter (velocity and acceleration)
- Motion of the projectile (acceleration, maximum
velocity, friction, wind resistance, gravity, and
so on). - Depending on the skill of the shooter, you can
tune how much compensation is actually done, and
add random deviation to the chosen direction to
avoid a perfect shot every time.
66Search TechniquesNavigation with Obstacles
- This problem is significantly more complex than
the case without obstacles. - We now need our artificial intelligence to route
characters around obstacles. - The path selected must meet several criteria
- It must be as short as possible, or the least
costly, depending on the situation. - It must look realistic and make sense to select
the path chosen. - It must be selected in a reasonable amount of
time without consuming too many scarce game
resources.
67Search TechniquesNavigation with Obstacles
- A leading approach to doing this is known as the
A or heuristic search. - There are several components to an A search
- A map (or graph) that A uses to find a path
between two positions. Maps are composed of
nodes that are connected if a direct path between
the nodes exists. - A cost associated with each direct connection
between map nodes. - A heuristic used to estimate the cost between two
map nodes that are not directly connected. It
must be an admissible heuristic that does not
overestimate the cost.
68Search TechniquesNavigation with Obstacles
- Each map node has three values associated with
it - g The cost to get from the start node to this
node. - h The estimated cost from this node to the goal
node. - f The sum of g and h representing our current
best guess of the cost of the path going through
this node. - A maintains two lists of nodes an Open list,
of nodes currently being explored, and a Closed
list, of nodes that have been completely explored.
69Search TechniquesNavigation with Obstacles
- The A algorithm
- Let S be the starting point.
- Compute g, h, and f for S.
- Add S to the empty Open list.
- Let B be the node from the Open list with the
lowest f value. - If B is the goal G, quit with success.
- If the Open list is empty, quit with failure.
- Let C be a node connected to B.
- Compute g, h, and f for C.
- If C is on the Open or Closed list, check if the
new path is better with a lower f value, and
update if necessary. - Otherwise, add C to the Open list.
- Repeat 5. for all connections, then add B to the
Closed list. - Repeat from 4.
70Search TechniquesNavigation with Obstacles
- There are many extensions to A
- Terrain based A that has variable costs based on
different types of terrain. - Hierarchical A to optimize paths for aesthetics.
- Tactical A to select paths based on certain
strategies (avoiding enemy detection, to gain
superior firing positions, and so on). - Dynamic A that compensates for obstacle and goal
movement throughout the map. - There are also many other search algorithms
besides A that are also effective.
71Search TechniquesNavigation with Obstacles
72Search TechniquesNavigation with Obstacles
- A can be expensive to compute, so we need to
make some optimizations. - The best way is to simplify the search space as
much as possible. - Use hierarchical pathfinding as much as possible,
as it simplifies the search space. - Make sure a good heuristic cost is used.
- Cautiously overestimate the heuristic cost, but
you must be careful with this. - Preallocate as many search resources as possible.
- Sometimes this is not the best approach
73Search TechniquesNavigation with Obstacles
- An alternative approach is to use precomputed
navigation meshes. - An invisible mesh is used to represent all of the
valid environment locations that can be occupied
by game characters. - This mesh can be traversed in an incredibly
efficient fashion using a variety of algorithms
to control character movement. - Objects of use to characters can be placed along
the mesh and searched for in an efficient fashion.
74Search TechniquesNavigation with Obstacles
- Navigation meshes can be used to facilitate what
would seem to be very complex and intelligent
behaviour. - Special points can be placed throughout the mesh,
along with special links, indicating other
actions can be successfully executed from those
locations. - This can be used to support jumping, crouching,
crawling, diving, climbing, and a variety of
other seemingly intricate behaviour with little
or no additional effort. - It makes characters seem smarter, but the smarts
are part of the levels, not the artificial
intelligence.
75Search TechniquesNavigation with Obstacles
Screen shot from the Unreal Tournament 2003
editor. Paths and path nodesare added to ensure
that bots can navigate the environment. If they
areabsent, the bots will not be able to move
around and will get lost.
76Rule Based SystemsFinite State Machines
- Finite state machines are simple and effective
approach to game artificial intelligence. - States represent the different game situations a
character can face. - On the occurrence of certain events, or with the
passage of time, the character will take certain
actions and will change to a new state. The new
state can either be a different state or the same
one. - By encoding the appropriate events and actions in
this fashion, state machines provide considerable
power with little complexity.
77Rule Based SystemsFinite State Machines
Opponent sighted in range Choose weapon, aim, and
fire
Not dead yet? Keep shooting
Running
Shooting
Opponent dead Go look for more
Out of ammunition Commence search
Hit jump point Start jumping
Done Go backto runsome more
Searching
Jumping
Simplified Finite State Machine for a First
Person Shooter AI
78Rule Based SystemsFinite State Machines
- There are also several extensions to the finite
state machine approach - Hierarchical finite state machines allow states
to be decomposed into their own separate finite
state machines capable of implementing the parent
state. - Nondeterministic finite state machines allow
multiple transitions on the same input event to
different states. This can be used to add
unpredictability to actions taken in a clean and
consistent fashion. Weights can be added to tune
the probability that the various transitions will
be selected. - Many more useful extensions exist.
79Rule Based SystemsFinite State Machines
Been shot at Return fire
Running
Shooting
Been shot at Evasive maneuvers
Been shot at Start jumping frenzy
Dodging
Jumping
Nondeterministic Finite State Machine for a First
Person Shooter AI
80Rule Based SystemsDecision Trees
- Decision trees are another approach to artificial
intelligence. - They are essentially complex if-then
conditionals organized as a tree. - Decisions based on a set of inputs are made by
starting at the trees root and, at each node,
selecting the next child node to visit based on
the values of the inputs. - The leafs of the tree contain the actions to take
if tree traversal reaches the leaf. - A variety of algorithms like ID3 and C4.5 can be
used to construct such trees.
81Rule Based SystemsDecision Trees
Am I being shot at?
Yes
No
Is it a gun or grenade?
Is an enemy in range?
Gun
Grenade
Yes
No
Aim and shoot!
Can one be found?
Strafe to dodge
Jump to dodge
Yes
No
Go after it
Get moreammunition
A Simplified Partial Decision Tree for a First
Person Shooter.
82Rule Based SystemsProduction Systems
- Production systems are essentially a database of
rules. - Each rule consists of an arbitrarily complex
conditional statement, and a set of actions to
execute if the conditional is satisfied. - Production systems are basically lists of
if-then statements, with various conflict
resolution mechanisms available in case more than
one rule is satisfied at the same time.
83Rule Based SystemsProduction Systems
- Some example rules for a production system for a
First Person Shooter - Enemy sighted
- Aim and shoot at enemy
- Out of ammunition
- Launch search for more ammunition
- Being shot at
- Execute evasive actions
84Game Theory and Game Trees
- Some games can be thought of and treated as
search problems quite effectively. - The different possible game states are
represented in a tree-like fashion. Different
moves in the game trigger transitions from a
parent state to its children states below. - This tree is searched starting from its root (the
current game state) to locate a game outcome
resulting in a victory or the highest possible
score for the player. - The set of tree nodes traversed indicates the set
of moves required to result in this situation.
85Game Theory and Game Trees
Current Position
A1
A2
A3
3
2
4
Ply 1
A11
A12
A13
A21
A22
A23
A31
A32
A33
Ply 2
3
12
8
2
4
6
14
5
2
A sample game tree for a game. After white
explores two plies of moves ahead, its best move
would be A1, to which yellow would respond with
A11 for a valueof 3. If white made a different
move, it would end up with a value of 2.
86Game Theory and Game Trees
- This approach can be very time consuming to
explore and evaluate the various plies of
possible moves. - It is usually impossible with most games to fully
explore all of the possibilities. - Often, different approaches need to be used to
improve overall efficiency. - Take advantage of opponent think time to explore
additional plies. - Prune the tree whenever possible to reduce the
number of possible moves to evaluate. - Apply game-specific heuristics to be selective
during the process of exploration. For example,
in chess, spend extra time exploring
queen-capturing moves.
87Game Theory and Game Trees
Screen shot from CompuChess. Games like Chess
and Go frequently make use of game trees. They
can be applicable elsewhere too imagine a
fighting game that has planned moves and counter
moves several plies deep!
88Artificial Life and Flocking Techniques
- Artificial life refers to systems of multiple
artificial intelligence agents that attempt to
apply some properties of living systems to
themselves in a virtual world. - For example, the agents can be given a variety of
basic needs that they must fulfill. Fulfilling
these needs typically requires other needs to be
met, and often leads to other needs as well. - Games such as SimCity and the Sims use these
techniques to provide very interesting and
entertaining gameplay.
89Artificial Life and Flocking Techniques
Screen shot from The Sims. The Sims makes use of
artificial life techniques extensively. For
example, Sims feel hungry after a while and will
do what they can to satisfy that need, which can
lead to complex behaviours.
90Artificial Life and Flocking Techniques
- Flocking is a subset of artificial life to
regulate and direct group behaviour. - Such systems employ the following general rules
of flocking behaviour - Separation steer to crowding local flockmates.
- Alignment steer toward the average heading of
local flockmates. - Cohesion steer to move toward the average
position of local flockmates. - Avoidance steer to avoid running into local
obstacles or other terrain features. - Survival steer to meet basic needs as necessary
or to avoid danger if a predator seen.
91Artificial Life and Flocking Techniques
Screen shots from several flocking programs with
different behaviours.
92Planning Techniques
- Planning techniques are an extension of search
methods that emphasize the subproblem of finding
the best sequence of actions to achieve a
particular result. - Start with an initial game world state.
- Also start with a precise definition of the
consequences of each possible action. - Planning then moves forward from the start, or
backwards from the desired result to discover the
sequence of actions required. - Such techniques have met with some success.
93Planning Techniques
Screen shot from Warcraft III. Game artificial
intelligence must formulate complex plans in
building units and structures, due to their
dependencies. (Other techniques could have been
used for the same result.)
94Fuzzy Logic
- Fuzzy logic uses real-valued numbers to represent
degrees of truth or set membership as opposed to
the Boolean (true or false) values of traditional
logic. - Fuzzy logic techniques allow for more expressive
reasoning and more richness and subtlety than
traditional logic. - They more accurately capture situations in which
things are not either black or white. - More often than not, things are shades of grey.
95Fuzzy Logic
Screen shot from Grand Theft Auto. Fuzzy logic
is good for modeling trafficbehaviour with
multiple autonomous drivers in a game such as
this to control braking, steering, and
acceleration to avoid accidents.
96Scripting
- Game artificial intelligence does not need to
spontaneously think up every behaviour performed
in a game. - A combination of dynamic and scripted behaviours
often works best. - If the game designer can make assumptions as to
what is happening in the game, scripted behaviour
can be used quite effectively. - For example, if a player is forced to enter a
room from a certain direction, scripting can be
used to provide an interesting challenge to the
player.
97Scripting
- When setting up scripts, the level designer must
be involved. - This way scripts can be written so that
characters can take advantages of level features,
such as hiding places, ambush locations, and game
items. - The game must also be able to detect when a
scripted plan is not working out. - It must switch to another script, or attempt some
kind of unscripted action. - Avoid predictability and ensure reactivity.
- Select scripts randomly, depending on the
situation. - Keep scripts short, and use them as building
blocks. - Try to build scripts that only provide hints of
actions.
98Scripting
Screen shot from Half-Life. This game was widely
praised for the strength of its artificial
intelligence. In fact, what was perceived as
intelligence was doneusing scripted paths that
game characters would follow in certain
situations.